Skip to content

Commit 8a617ed

Browse files
committed
Bump Clouseau to 2.23.1
The latest version of Clouseau now fixes the incompatibility issue with OTP 26 and later [1], so pull that in and remove the related checks. At the same time, replace SLF4J Simple with Logback Classic [2] since that has been the standard logging backend for a while. Note that Clouseau is still shipped with SLF4J API 1.7, which supports Logback up to 1.2 only. [1] Thanks @jaydoane! [2] https://logback.qos.ch/
1 parent fcbee88 commit 8a617ed

File tree

3 files changed

+63
-41
lines changed

3 files changed

+63
-41
lines changed

configure

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ JS_ENGINE=${JS_ENGINE:-"spidermonkey"}
4343
SM_VSN=${SM_VSN:-"91"}
4444
CLOUSEAU_MTH=${CLOUSEAU_MTH:-"dist"}
4545
CLOUSEAU_URI=${CLOUSEAU_URI:-"https://github.com/cloudant-labs/clouseau/releases/download/%s/clouseau-%s-dist.zip"}
46-
CLOUSEAU_VSN=${CLOUSEAU_VSN:-"2.22.0"}
46+
CLOUSEAU_VSN=${CLOUSEAU_VSN:-"2.23.1"}
4747
CLOUSEAU_DIR="$(pwd)"/clouseau
4848
ARCH="$(uname -m)"
4949
ERLANG_VER="$(run_erlang 'io:put_chars(erlang:system_info(otp_release)).')"
@@ -111,16 +111,11 @@ parse_opts() {
111111
continue
112112
;;
113113

114-
--with-clouseau)
115-
if [ "${ERLANG_VER}" -gt 25 ]; then
116-
echo "Warning: Clouseau is not working with OTP 26 or later at the moment, therefore it is not configured. Continue in 5 seconds..."
117-
sleep 5
118-
else
119-
WITH_CLOUSEAU="true"
120-
fi
121-
shift
122-
continue
123-
;;
114+
--with-clouseau)
115+
WITH_CLOUSEAU="true"
116+
shift
117+
continue
118+
;;
124119

125120
--erlang-md5)
126121
ERLANG_MD5="true"
@@ -475,24 +470,35 @@ check_local_clouseau_dir() {
475470
fi
476471
}
477472

473+
fetch_file() {
474+
_file_name="$1"
475+
_file_url="$2"
476+
477+
if ! curl -sSL --max-redirs 1 -o "$_file_name" "$_file_url"; then
478+
printf "ERROR: %s could not be downloaded.\n" "$_file_url" >&2
479+
exit 1
480+
fi
481+
}
482+
478483
install_local_clouseau() {
479484
case "$CLOUSEAU_MTH" in
480485
dist)
481486
_DIST_URL=$(printf "$CLOUSEAU_URI" "$CLOUSEAU_VSN" "$CLOUSEAU_VSN")
482487
_MAVEN_BASE_URI=https://repo1.maven.org/maven2
488+
_LOGBACK_DIST_URL="$_MAVEN_BASE_URI"/ch/qos/logback
483489

484-
_SLF4J_SIMPLE_VSN=${SLF4J_SIMPLE_VERSION:-1.7.36}
485-
_SLF4J_SIMPLE_JAR=slf4j-simple-"$_SLF4J_SIMPLE_VSN".jar
486-
_SLF4J_SIMPLE_URL="$_MAVEN_BASE_URI"/org/slf4j/slf4j-simple/"$_SLF4J_SIMPLE_VSN"/"$_SLF4J_SIMPLE_JAR"
490+
: "${LOGBACK_VERSION:=1.2.13}"
491+
_LOGBACK_CORE_JAR=logback-core-"$LOGBACK_VERSION".jar
492+
_LOGBACK_CORE_URL="$_LOGBACK_DIST_URL"/logback-core/"$LOGBACK_VERSION"/"$_LOGBACK_CORE_JAR"
493+
_LOGBACK_CLASSIC_JAR=logback-classic-"$LOGBACK_VERSION".jar
494+
_LOGBACK_CLASSIC_URL="$_LOGBACK_DIST_URL"/logback-classic/"$LOGBACK_VERSION"/"$_LOGBACK_CLASSIC_JAR"
487495

488496
check_local_clouseau_dir "$CLOUSEAU_DIR"
489497
mkdir -p "$CLOUSEAU_DIR"
490498

491499
echo "Fetching Clouseau from $_DIST_URL..."
492-
if ! curl -sSL --max-redirs 1 -o clouseau.zip "$_DIST_URL"; then
493-
printf "ERROR: %s could not be downloaded.\n" "$_DIST_URL" >&2
494-
exit 1
495-
fi
500+
501+
fetch_file clouseau.zip "$_DIST_URL"
496502

497503
if ! unzip -q -j clouseau.zip -d "$CLOUSEAU_DIR"; then
498504
printf "ERROR: Clouseau distribution package (clouseau.zip) could not be extracted.\n" >&2
@@ -501,10 +507,10 @@ install_local_clouseau() {
501507

502508
rm clouseau.zip
503509

504-
if ! curl -sSL --max-redirs 1 -o "$CLOUSEAU_DIR"/"$_SLF4J_SIMPLE_JAR" "$_SLF4J_SIMPLE_URL"; then
505-
printf "ERROR: %s could not be downloaded.\n" "$_SLF4J_SIMPLE_URL" >&2
506-
exit 1
507-
fi
510+
echo "Fetching Logback $LOGBACK_VERSION from $_LOGBACK_DIST_URL..."
511+
512+
fetch_file "$CLOUSEAU_DIR"/"$_LOGBACK_CORE_JAR" "$_LOGBACK_CORE_URL"
513+
fetch_file "$CLOUSEAU_DIR"/"$_LOGBACK_CLASSIC_JAR" "$_LOGBACK_CLASSIC_URL"
508514
;;
509515

510516
git)

configure.ps1

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
-CouchDBUser USER set the username to run as (defaults to current user)
1515
-SpiderMonkeyVersion VSN select the version of SpiderMonkey to use (default 91)
1616
-JSEngine ENGINE select JS engine to use (spidermonkey or quickjs) (default spidermonkey)
17-
-ClouseauVersion VSN select the version of Clouseau to use (default 2.22.0)
17+
-ClouseauVersion VSN select the version of Clouseau to use (default 2.23.1)
1818
-ClouseauMethod MTH method for Clouseau to deploy: git or dist (default dist)
19-
-ClouseauUri URI location for retrieving Clouseau (default https://github.com/cloudant-labs/clouseau/releases/download/2.22.0/clouseau-2.22.0-dist.zip)
19+
-ClouseauUri URI location for retrieving Clouseau (default https://github.com/cloudant-labs/clouseau/releases/download/2.23.1/clouseau-2.23.1-dist.zip)
2020
2121
Installation directories:
2222
-Prefix PREFIX install architecture-independent files in PREFIX
@@ -66,9 +66,9 @@ Param(
6666
[ValidateNotNullOrEmpty()]
6767
[string]$ClouseauMethod = "dist", # method for Clouseau to deploy: git or dist (default dist)
6868
[ValidateNotNullOrEmpty()]
69-
[string]$ClouseauVersion = "2.22.0", # select the version of Clouseau to use (default 2.22.0)
69+
[string]$ClouseauVersion = "2.23.1", # select the version of Clouseau to use (default 2.23.1)
7070
[ValidateNotNullOrEmpty()]
71-
[string]$ClouseauUri = "https://github.com/cloudant-labs/clouseau/releases/download/{0}/clouseau-{0}-dist.zip", # location for retrieving Clouseau (default https://github.com/cloudant-labs/clouseau/releases/download/2.22.0/clouseau-2.22.0-dist.zip)
71+
[string]$ClouseauUri = "https://github.com/cloudant-labs/clouseau/releases/download/{0}/clouseau-{0}-dist.zip", # location for retrieving Clouseau (default https://github.com/cloudant-labs/clouseau/releases/download/2.23.1/clouseau-2.23.1-dist.zip)
7272
[ValidateNotNullOrEmpty()]
7373
[string]$Prefix = "C:\Program Files\Apache\CouchDB", # install architecture-independent file location (default C:\Program Files\Apache\CouchDB)
7474
[ValidateNotNullOrEmpty()]
@@ -321,10 +321,12 @@ if ($WithClouseau)
321321

322322
New-Item -Path $ClouseauDir -ItemType Directory | Out-Null
323323

324-
$Slf4jVersion = "1.7.36"
324+
$LogbackVersion = "1.2.13"
325325
$ClouseauDistUrl = $ClouseauUri -f $ClouseauVersion
326-
$Slf4jSimpleJar = "slf4j-simple-$Slf4jVersion.jar"
327-
$Slf4jSimpleUrl = "https://repo1.maven.org/maven2/org/slf4j/slf4j-simple/$Slf4jVersion/$Slf4jSimpleJar"
326+
$LogbackCoreJar = "logback-core-$LogbackVersion.jar"
327+
$LogbackCoreJarUrl = "https://repo1.maven.org/maven2/ch/qos/logback/logback-core/$LogbackVersion/$LogbackCoreJar"
328+
$LogbackClassicJar = "logback-classic-$LogbackVersion.jar"
329+
$LogbackClassicJarUrl = "https://repo1.maven.org/maven2/ch/qos/logback/logback-classic/$LogbackVersion/$LogbackClassicJar"
328330

329331
Set-Variable ProgressPreference SilentlyContinue
330332
Invoke-WebRequest -MaximumRedirection 1 -OutFile clouseau.zip $ClouseauDistUrl
@@ -342,9 +344,15 @@ if ($WithClouseau)
342344
Remove-Item "$ClouseauDir\clouseau-$ClouseauVersion"
343345
Remove-Item clouseau.zip
344346

345-
Invoke-WebRequest -MaximumRedirection 1 -OutFile "$ClouseauDir\$Slf4jSimpleJar" $Slf4jSimpleUrl
347+
Invoke-WebRequest -MaximumRedirection 1 -OutFile "$ClouseauDir\$LogbackCoreJar" $LogbackCoreJarUrl
346348
If ($LASTEXITCODE -ne 0) {
347-
Write-Output "ERROR: $Slf4jSimpleJarUrl could not be downloaded."
349+
Write-Output "ERROR: $LogbackCoreJarUrl could not be downloaded."
350+
exit 1
351+
}
352+
353+
Invoke-WebRequest -MaximumRedirection 1 -OutFile "$ClouseauDir\$LogbackClassicJar" $LogbackClassicJarUrl
354+
If ($LASTEXITCODE -ne 0) {
355+
Write-Output "ERROR: $LogbackClassicJarUrl could not be downloaded."
348356
exit 1
349357
}
350358
}

dev/run

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -592,14 +592,21 @@ def generate_default_clouseau_ini(path):
592592
)
593593

594594

595-
def generate_default_log4j_properties(path):
596-
print("(generate default log4j.properties)")
595+
def generate_default_logback_properties(path):
596+
print("(generate default logback.xml)")
597597
with open(path, "w") as handle:
598598
handle.write(
599-
"""log4j.rootLogger=debug, CONSOLE
600-
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
601-
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
602-
log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} %c [%p] %m%n
599+
"""<configuration>
600+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
601+
<encoder>
602+
<pattern>%d{ISO8601} %c [%p] %m%n</pattern>
603+
</encoder>
604+
</appender>
605+
606+
<root level="debug">
607+
<appender-ref ref="STDOUT"/>
608+
</root>
609+
</configuration>
603610
"""
604611
)
605612

@@ -714,9 +721,11 @@ def boot_clouseau(ctx, idx):
714721
if not os.path.exists(clouseau_ini):
715722
generate_default_clouseau_ini(clouseau_ini)
716723

717-
log4j_properties = os.path.join(clouseau_dir, "log4j.properties")
718-
if not os.path.exists(log4j_properties):
719-
generate_default_log4j_properties(log4j_properties)
724+
logback_properties = os.path.join(clouseau_dir, "logback.xml")
725+
if not os.path.exists(logback_properties):
726+
generate_default_logback_properties(logback_properties)
727+
728+
classpath = separator.join([classpath, clouseau_dir]) # for logback.xml
720729

721730
clouseau_name = "clouseau{}@127.0.0.1".format(idx)
722731
clouseau_indexes_dir = os.path.join(ctx["devdir"], "clouseau{}".format(idx), "data")
@@ -745,7 +754,6 @@ def boot_clouseau(ctx, idx):
745754
"-XX:+CMSParallelRemarkEnabled",
746755
"-cp",
747756
classpath,
748-
"-Dlog4j.configuration=file:{}".format(log4j_properties),
749757
"-Dclouseau.name={}".format(clouseau_name),
750758
"-Dclouseau.dir={}".format(clouseau_indexes_dir),
751759
]

0 commit comments

Comments
 (0)