mirror of
https://github.com/ACINQ/eclair.git
synced 2025-03-11 01:35:01 +01:00
Rework packaging (#1307)
* Replace maven-capsule-plugin with maven-assembly-plugin in eclair-node and eclair-node-gui: The new packaging produces a zip file containing a launcher script and all the artifacts and dependencies in lib/. * Add bash launcher scripts for eclair-node and eclair-node-gui, inspired by https://github.com/sbt/sbt-native-packager/blob/master/src/main/resources/com/typesafe/sbt/packager/archetypes/scripts/bash-template * Add windows launcher scripts, inspired by https://github.com/sbt/sbt-native-packager/blob/master/src/main/resources/com/typesafe/sbt/packager/archetypes/scripts/bat-template * Add option to start kanela agent with eclair-node launcher scripts * Force unix file ending in launcher scripts * Add eclair-cli in the bin folder of packaged eclair-node and eclair-node-gui
This commit is contained in:
parent
cc4a4ab2c7
commit
a0286458c6
12 changed files with 1258 additions and 58 deletions
13
BUILD.md
13
BUILD.md
|
@ -8,15 +8,14 @@
|
|||
|
||||
## Build
|
||||
|
||||
Eclair supports deterministic builds for the eclair-core submodule, this is the 'core' of the eclair application
|
||||
and its artifact can be deterministically built achieving byte-to-byte equality for each build. To build the exact
|
||||
same artifacts that we release, you must use the build environment (OS, JDK, maven...) that we specify in our
|
||||
release notes.
|
||||
Eclair is packaged as a compressed archive with a launcher script, the archives are built deterministically
|
||||
so it's possible to reproduce the build and verify its equality byte-by-byte. To build the exact same artifacts
|
||||
that we release, you must use the build environment (OS, JDK, maven...) that we specify in our release notes.
|
||||
|
||||
To build the project and run the tests, simply run:
|
||||
|
||||
```shell
|
||||
mvn install
|
||||
mvn package
|
||||
```
|
||||
|
||||
### Other build options
|
||||
|
@ -24,13 +23,13 @@ mvn install
|
|||
To skip all tests, run:
|
||||
|
||||
```shell
|
||||
mvn install -DskipTests
|
||||
mvn package -DskipTests
|
||||
```
|
||||
|
||||
To only build the `eclair-node` module, run:
|
||||
|
||||
```shell
|
||||
mvn install -pl eclair-node -am -DskipTests
|
||||
mvn package -pl eclair-node -am -DskipTests
|
||||
```
|
||||
|
||||
To run the tests, run:
|
||||
|
|
12
Dockerfile
12
Dockerfile
|
@ -28,6 +28,8 @@ COPY pom.xml pom.xml
|
|||
COPY eclair-core/pom.xml eclair-core/pom.xml
|
||||
COPY eclair-node/pom.xml eclair-node/pom.xml
|
||||
COPY eclair-node-gui/pom.xml eclair-node-gui/pom.xml
|
||||
COPY eclair-node/modules/eclair-node.xml eclair-node/modules/eclair-node.xml
|
||||
COPY eclair-node-gui/modules/eclair-node-gui.xml eclair-node-gui/modules/eclair-node-gui.xml
|
||||
RUN mkdir -p eclair-core/src/main/scala && touch eclair-core/src/main/scala/empty.scala
|
||||
# Blank build. We only care about eclair-node, and we use install because eclair-node depends on eclair-core
|
||||
RUN mvn install -pl eclair-node -am
|
||||
|
@ -45,15 +47,15 @@ FROM openjdk:11.0.4-jre-slim
|
|||
WORKDIR /app
|
||||
|
||||
# install jq for eclair-cli
|
||||
RUN apt-get update && apt-get install -y bash jq curl
|
||||
RUN apt-get update && apt-get install -y bash jq curl unzip
|
||||
|
||||
# copy and install eclair-cli executable
|
||||
COPY --from=BUILD /usr/src/eclair-core/eclair-cli .
|
||||
RUN chmod +x eclair-cli && mv eclair-cli /sbin/eclair-cli
|
||||
|
||||
# Eclair only needs the eclair-node-*.jar to run
|
||||
COPY --from=BUILD /usr/src/eclair-node/target/eclair-node-*.jar .
|
||||
RUN ln `ls` eclair-node.jar
|
||||
# we only need the eclair-node.zip to run
|
||||
COPY --from=BUILD /usr/src/eclair-node/target/eclair-node-*.zip ./eclair-node.zip
|
||||
RUN unzip eclair-node.zip && mv eclair-node-* eclair-node
|
||||
|
||||
ENV ECLAIR_DATADIR=/data
|
||||
ENV JAVA_OPTS=
|
||||
|
@ -61,4 +63,4 @@ ENV JAVA_OPTS=
|
|||
RUN mkdir -p "$ECLAIR_DATADIR"
|
||||
VOLUME [ "/data" ]
|
||||
|
||||
ENTRYPOINT java $JAVA_OPTS -Declair.datadir=$ECLAIR_DATADIR -jar eclair-node.jar
|
||||
ENTRYPOINT $JAVA_OPTS eclair-node/bin/eclair-node.sh -Declair.datadir=$ECLAIR_DATADIR
|
||||
|
|
14
README.md
14
README.md
|
@ -65,25 +65,25 @@ zmqpubrawtx=tcp://127.0.0.1:29000
|
|||
|
||||
### Installing Eclair
|
||||
|
||||
Eclair is developed in [Scala](https://www.scala-lang.org/), a powerful functional language that runs on the JVM, and is packaged as a JAR (Java Archive) file. We provide 2 different packages, which internally use the same core libraries:
|
||||
Eclair is developed in [Scala](https://www.scala-lang.org/), a powerful functional language that runs on the JVM, and is packaged as a ZIP archive. We provide 2 different packages, which internally use the same core libraries:
|
||||
|
||||
* eclair-node, which is a headless application that you can run on servers and desktops, and control from the command line
|
||||
* eclair-node-gui, which also includes a JavaFX GUI
|
||||
|
||||
To run Eclair, you first need to install Java, we recommend that you use [OpenJDK 11](https://adoptopenjdk.net/?variant=openjdk11&jvmVariant=hotspot). Other runtimes also work but we don't recommend using them.
|
||||
|
||||
Then download our latest [release](https://github.com/ACINQ/eclair/releases) and depending on whether or not you want a GUI run the following command:
|
||||
Then download our latest [release](https://github.com/ACINQ/eclair/releases), unzip the archive and depending on whether or not you want a GUI run the following command:
|
||||
|
||||
* with GUI:
|
||||
|
||||
```shell
|
||||
java -jar eclair-node-gui-<version>-<commit_id>.jar
|
||||
eclair-node-gui-<version>-<commit_id>/bin/eclair-node-gui.sh
|
||||
```
|
||||
|
||||
* without GUI:
|
||||
|
||||
```shell
|
||||
java -jar eclair-node-<version>-<commit_id>.jar
|
||||
eclair-node-<version>-<commit_id>/bin/eclair-node.sh
|
||||
```
|
||||
|
||||
### Configuring Eclair
|
||||
|
@ -133,7 +133,7 @@ eclair.printToConsole | Log to stdout (in addition to eclair.log) |
|
|||
For example, to specify a different data directory you would run the following command:
|
||||
|
||||
```shell
|
||||
java -Declair.datadir=/tmp/node1 -jar eclair-node-gui-<version>-<commit_id>.jar
|
||||
eclair-node-<version>-<commit_id>/bin/eclair-node.sh -Declair.datadir=/tmp/node1
|
||||
```
|
||||
|
||||
#### Logging
|
||||
|
@ -141,7 +141,7 @@ java -Declair.datadir=/tmp/node1 -jar eclair-node-gui-<version>-<commit_id>.jar
|
|||
Eclair uses [`logback`](https://logback.qos.ch) for logging. To use a different configuration, and override the internal logback.xml, run:
|
||||
|
||||
```shell
|
||||
java -Dlogback.configurationFile=/path/to/logback-custom.xml -jar eclair-node-gui-<version>-<commit_id>.jar
|
||||
eclair-node-<version>-<commit_id>/bin/eclair-node.sh -Dlogback.configurationFile=/path/to/logback-custom.xml
|
||||
```
|
||||
|
||||
#### Backup
|
||||
|
@ -197,7 +197,7 @@ A valid plugin is a jar that contains an implementation of the [Plugin](eclair-n
|
|||
Here is how to run Eclair with plugins:
|
||||
|
||||
```shell
|
||||
java -jar eclair-node-<version>-<commit_id>.jar <plugin1.jar> <plugin2.jar> <...>
|
||||
eclair-node-<version>-<commit_id>/bin/eclair-node.sh <plugin1.jar> <plugin2.jar> <...>
|
||||
```
|
||||
|
||||
## Testnet usage
|
||||
|
|
44
eclair-node-gui/modules/assembly.xml
Normal file
44
eclair-node-gui/modules/assembly.xml
Normal file
|
@ -0,0 +1,44 @@
|
|||
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
|
||||
<id>bin</id>
|
||||
<formats>
|
||||
<format>zip</format>
|
||||
</formats>
|
||||
<dependencySets> <!-- include dependencies -->
|
||||
<dependencySet>
|
||||
<outputDirectory>lib</outputDirectory>
|
||||
<useProjectArtifact>true</useProjectArtifact> <!-- include eclair-core and eclair node -->
|
||||
<unpack>false</unpack>
|
||||
<scope>runtime</scope>
|
||||
</dependencySet>
|
||||
</dependencySets>
|
||||
<fileSets> <!-- Include readme and license -->
|
||||
<fileSet>
|
||||
<directory>../</directory>
|
||||
<includes>
|
||||
<include>README.md</include>
|
||||
<include>LICENSE*</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
<fileSet> <!-- Include the launcher scripts -->
|
||||
<directory>${project.basedir}/src/main/resources</directory>
|
||||
<outputDirectory>bin</outputDirectory>
|
||||
<includes>
|
||||
<include>eclair-node-gui.sh</include>
|
||||
<include>eclair-node-gui.bat</include>
|
||||
</includes>
|
||||
<fileMode>0755</fileMode>
|
||||
<lineEnding>unix</lineEnding>
|
||||
</fileSet>
|
||||
<fileSet> <!-- Include eclair-cli -->
|
||||
<directory>../eclair-core/</directory>
|
||||
<outputDirectory>bin</outputDirectory>
|
||||
<includes>
|
||||
<include>eclair-cli</include>
|
||||
</includes>
|
||||
<fileMode>0755</fileMode>
|
||||
<lineEnding>unix</lineEnding>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</assembly>
|
|
@ -49,19 +49,25 @@
|
|||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.github.chrisdchristo</groupId>
|
||||
<artifactId>capsule-maven-plugin</artifactId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<finalName>${project.name}-${project.version}-${git.commit.id.abbrev}</finalName>
|
||||
<descriptors>
|
||||
<descriptor>modules/assembly.xml</descriptor>
|
||||
</descriptors>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>fr.acinq.eclair.JavafxBoot</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<appClass>fr.acinq.eclair.JavafxBoot</appClass>
|
||||
<type>fat</type>
|
||||
<fileName>${project.name}-${project.version}</fileName>
|
||||
<fileDesc>-${git.commit.id.abbrev}</fileDesc>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
|
192
eclair-node-gui/src/main/resources/eclair-node-gui.bat
Normal file
192
eclair-node-gui/src/main/resources/eclair-node-gui.bat
Normal file
|
@ -0,0 +1,192 @@
|
|||
@REM Copyright (c) 2012, Joshua Suereth
|
||||
@REM All rights reserved.
|
||||
@REM
|
||||
@REM Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
@REM
|
||||
@REM Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
@REM Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
@REM THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@REM @@APP_NAME@@ launcher script
|
||||
@REM
|
||||
@REM Environment:
|
||||
@REM JAVA_HOME - location of a JDK home dir (optional if java on path)
|
||||
@REM CFG_OPTS - JVM options (optional)
|
||||
@REM Configuration:
|
||||
@REM @@APP_ENV_NAME@@_config.txt found in the @@APP_ENV_NAME@@_HOME.
|
||||
@setlocal enabledelayedexpansion
|
||||
@setlocal enableextensions
|
||||
|
||||
@echo off
|
||||
|
||||
|
||||
if "%@@APP_ENV_NAME@@_HOME%"=="" (
|
||||
set "APP_HOME=%~dp0\\.."
|
||||
|
||||
rem Also set the old env name for backwards compatibility
|
||||
set "@@APP_ENV_NAME@@_HOME=%~dp0\\.."
|
||||
) else (
|
||||
set "APP_HOME=%@@APP_ENV_NAME@@_HOME%"
|
||||
)
|
||||
|
||||
set "APP_LIB_DIR=%APP_HOME%\lib\"
|
||||
|
||||
rem Detect if we were double clicked, although theoretically A user could
|
||||
rem manually run cmd /c
|
||||
for %%x in (!cmdcmdline!) do if %%~x==/c set DOUBLECLICKED=1
|
||||
|
||||
rem FIRST we load the config file of extra options.
|
||||
set "CFG_FILE=%APP_HOME%\@@APP_ENV_NAME@@_config.txt"
|
||||
set CFG_OPTS=
|
||||
call :parse_config "%CFG_FILE%" CFG_OPTS
|
||||
|
||||
rem We use the value of the JAVA_OPTS environment variable if defined, rather than the config.
|
||||
set _JAVA_OPTS=%JAVA_OPTS%
|
||||
if "!_JAVA_OPTS!"=="" set _JAVA_OPTS=!CFG_OPTS!
|
||||
|
||||
rem We keep in _JAVA_PARAMS all -J-prefixed and -D-prefixed arguments
|
||||
rem "-J" is stripped, "-D" is left as is, and everything is appended to JAVA_OPTS
|
||||
set _JAVA_PARAMS=
|
||||
set _APP_ARGS=
|
||||
|
||||
for /f %%i in ('dir /b %APP_LIB_DIR%\eclair-node-gui*') do set APP_ENTRYPOINT=%%i
|
||||
set CUSTOM_MAIN_CLASS="fr.acinq.eclair.JavafxBoot"
|
||||
set APP_CLASSPATH="%APP_LIB_DIR%;%APP_LIB_DIR%/%APP_ENTRYPOINT%"
|
||||
|
||||
rem Bundled JRE has priority over standard environment variables
|
||||
if defined BUNDLED_JVM (
|
||||
set "_JAVACMD=%BUNDLED_JVM%\bin\java.exe"
|
||||
) else (
|
||||
if "%JAVACMD%" neq "" (
|
||||
set "_JAVACMD=%JAVACMD%"
|
||||
) else (
|
||||
if "%JAVA_HOME%" neq "" (
|
||||
if exist "%JAVA_HOME%\bin\java.exe" set "_JAVACMD=%JAVA_HOME%\bin\java.exe"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if "%_JAVACMD%"=="" set _JAVACMD=java
|
||||
|
||||
rem Detect if this java is ok to use.
|
||||
for /F %%j in ('"%_JAVACMD%" -version 2^>^&1') do (
|
||||
if %%~j==java set JAVAINSTALLED=1
|
||||
if %%~j==openjdk set JAVAINSTALLED=1
|
||||
)
|
||||
|
||||
rem BAT has no logical or, so we do it OLD SCHOOL! Oppan Redmond Style
|
||||
set JAVAOK=true
|
||||
if not defined JAVAINSTALLED set JAVAOK=false
|
||||
|
||||
if "%JAVAOK%"=="false" (
|
||||
echo.
|
||||
echo A Java JDK is not installed or can't be found.
|
||||
if not "%JAVA_HOME%"=="" (
|
||||
echo JAVA_HOME = "%JAVA_HOME%"
|
||||
)
|
||||
echo.
|
||||
echo Please go to
|
||||
echo https://adoptopenjdk.net/?variant=openjdk11&jvmVariant=hotspot
|
||||
echo and download a valid Java JDK and install before running @@APP_NAME@@.
|
||||
echo.
|
||||
echo If you think this message is in error, please check
|
||||
echo your environment variables to see if "java.exe" and "javac.exe" are
|
||||
echo available via JAVA_HOME or PATH.
|
||||
echo.
|
||||
if defined DOUBLECLICKED pause
|
||||
exit /B 1
|
||||
)
|
||||
|
||||
rem if configuration files exist, prepend their contents to the script arguments so it can be processed by this runner
|
||||
call :parse_config "%SCRIPT_CONF_FILE%" SCRIPT_CONF_ARGS
|
||||
|
||||
call :process_args %SCRIPT_CONF_ARGS% %%*
|
||||
|
||||
set _JAVA_OPTS=!_JAVA_OPTS! !_JAVA_PARAMS!
|
||||
|
||||
if defined CUSTOM_MAIN_CLASS (
|
||||
set MAIN_CLASS=!CUSTOM_MAIN_CLASS!
|
||||
) else (
|
||||
set MAIN_CLASS=!APP_MAIN_CLASS!
|
||||
)
|
||||
|
||||
rem Call the application and pass all arguments unchanged.
|
||||
"%_JAVACMD%" !_JAVA_OPTS! !@@APP_ENV_NAME@@_OPTS! -cp %APP_CLASSPATH% %MAIN_CLASS% !_APP_ARGS!
|
||||
|
||||
@endlocal
|
||||
|
||||
exit /B %ERRORLEVEL%
|
||||
|
||||
|
||||
rem Loads a configuration file full of default command line options for this script.
|
||||
rem First argument is the path to the config file.
|
||||
rem Second argument is the name of the environment variable to write to.
|
||||
:parse_config
|
||||
set _PARSE_FILE=%~1
|
||||
set _PARSE_OUT=
|
||||
if exist "%_PARSE_FILE%" (
|
||||
FOR /F "tokens=* eol=# usebackq delims=" %%i IN ("%_PARSE_FILE%") DO (
|
||||
set _PARSE_OUT=!_PARSE_OUT! %%i
|
||||
)
|
||||
)
|
||||
set %2=!_PARSE_OUT!
|
||||
exit /B 0
|
||||
|
||||
|
||||
:add_java
|
||||
set _JAVA_PARAMS=!_JAVA_PARAMS! %*
|
||||
exit /B 0
|
||||
|
||||
|
||||
:add_app
|
||||
set _APP_ARGS=!_APP_ARGS! %*
|
||||
exit /B 0
|
||||
|
||||
|
||||
rem Processes incoming arguments and places them in appropriate global variables
|
||||
:process_args
|
||||
:param_loop
|
||||
call set _PARAM1=%%1
|
||||
set "_TEST_PARAM=%~1"
|
||||
|
||||
if ["!_PARAM1!"]==[""] goto param_afterloop
|
||||
|
||||
|
||||
rem ignore arguments that do not start with '-'
|
||||
if "%_TEST_PARAM:~0,1%"=="-" goto param_java_check
|
||||
set _APP_ARGS=!_APP_ARGS! !_PARAM1!
|
||||
shift
|
||||
goto param_loop
|
||||
|
||||
:param_java_check
|
||||
if "!_TEST_PARAM:~0,2!"=="-J" (
|
||||
rem strip -J prefix
|
||||
set _JAVA_PARAMS=!_JAVA_PARAMS! !_TEST_PARAM:~2!
|
||||
shift
|
||||
goto param_loop
|
||||
)
|
||||
|
||||
if "!_TEST_PARAM:~0,2!"=="-D" (
|
||||
rem test if this was double-quoted property "-Dprop=42"
|
||||
for /F "delims== tokens=1,*" %%G in ("!_TEST_PARAM!") DO (
|
||||
if not ["%%H"] == [""] (
|
||||
set _JAVA_PARAMS=!_JAVA_PARAMS! !_PARAM1!
|
||||
) else if [%2] neq [] (
|
||||
rem it was a normal property: -Dprop=42 or -Drop="42"
|
||||
call set _PARAM1=%%1=%%2
|
||||
set _JAVA_PARAMS=!_JAVA_PARAMS! !_PARAM1!
|
||||
shift
|
||||
)
|
||||
)
|
||||
) else (
|
||||
if "!_TEST_PARAM!"=="-main" (
|
||||
call set CUSTOM_MAIN_CLASS=%%2
|
||||
shift
|
||||
) else (
|
||||
set _APP_ARGS=!_APP_ARGS! !_PARAM1!
|
||||
)
|
||||
)
|
||||
shift
|
||||
goto param_loop
|
||||
:param_afterloop
|
||||
|
||||
exit /B 0
|
360
eclair-node-gui/src/main/resources/eclair-node-gui.sh
Executable file
360
eclair-node-gui/src/main/resources/eclair-node-gui.sh
Executable file
|
@ -0,0 +1,360 @@
|
|||
# Copyright (c) 2012, Joshua Suereth
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
# Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#!/usr/bin/env bash
|
||||
|
||||
### ------------------------------- ###
|
||||
### Helper methods for BASH scripts ###
|
||||
### ------------------------------- ###
|
||||
|
||||
die() {
|
||||
echo "$@" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
realpath () {
|
||||
(
|
||||
TARGET_FILE="$1"
|
||||
CHECK_CYGWIN="$2"
|
||||
|
||||
cd "$(dirname "$TARGET_FILE")"
|
||||
TARGET_FILE=$(basename "$TARGET_FILE")
|
||||
|
||||
COUNT=0
|
||||
while [ -L "$TARGET_FILE" -a $COUNT -lt 100 ]
|
||||
do
|
||||
TARGET_FILE=$(readlink "$TARGET_FILE")
|
||||
cd "$(dirname "$TARGET_FILE")"
|
||||
TARGET_FILE=$(basename "$TARGET_FILE")
|
||||
COUNT=$(($COUNT + 1))
|
||||
done
|
||||
|
||||
if [ "$TARGET_FILE" == "." -o "$TARGET_FILE" == ".." ]; then
|
||||
cd "$TARGET_FILE"
|
||||
TARGET_FILEPATH=
|
||||
else
|
||||
TARGET_FILEPATH=/$TARGET_FILE
|
||||
fi
|
||||
|
||||
# make sure we grab the actual windows path, instead of cygwin's path.
|
||||
if [[ "x$CHECK_CYGWIN" == "x" ]]; then
|
||||
echo "$(pwd -P)/$TARGET_FILE"
|
||||
else
|
||||
echo $(cygwinpath "$(pwd -P)/$TARGET_FILE")
|
||||
fi
|
||||
)
|
||||
}
|
||||
|
||||
# TODO - Do we need to detect msys?
|
||||
|
||||
# Uses uname to detect if we're in the odd cygwin environment.
|
||||
is_cygwin() {
|
||||
local os=$(uname -s)
|
||||
case "$os" in
|
||||
CYGWIN*) return 0 ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# This can fix cygwin style /cygdrive paths so we get the
|
||||
# windows style paths.
|
||||
cygwinpath() {
|
||||
local file="$1"
|
||||
if is_cygwin; then
|
||||
echo $(cygpath -w $file)
|
||||
else
|
||||
echo $file
|
||||
fi
|
||||
}
|
||||
|
||||
# Make something URI friendly
|
||||
make_url() {
|
||||
url="$1"
|
||||
local nospaces=${url// /%20}
|
||||
if is_cygwin; then
|
||||
echo "/${nospaces//\\//}"
|
||||
else
|
||||
echo "$nospaces"
|
||||
fi
|
||||
}
|
||||
|
||||
# This crazy function reads in a vanilla "linux" classpath string (only : are separators, and all /),
|
||||
# and returns a classpath with windows style paths, and ; separators.
|
||||
fixCygwinClasspath() {
|
||||
OLDIFS=$IFS
|
||||
IFS=":"
|
||||
read -a classpath_members <<< "$1"
|
||||
declare -a fixed_members
|
||||
IFS=$OLDIFS
|
||||
for i in "${!classpath_members[@]}"
|
||||
do
|
||||
fixed_members[i]=$(realpath "${classpath_members[i]}" "fix")
|
||||
done
|
||||
IFS=";"
|
||||
echo "${fixed_members[*]}"
|
||||
IFS=$OLDIFS
|
||||
}
|
||||
|
||||
# Fix the classpath we use for cygwin.
|
||||
fix_classpath() {
|
||||
cp="$1"
|
||||
if is_cygwin; then
|
||||
echo "$(fixCygwinClasspath "$cp")"
|
||||
else
|
||||
echo "$cp"
|
||||
fi
|
||||
}
|
||||
# Detect if we should use JAVA_HOME or just try PATH.
|
||||
get_java_cmd() {
|
||||
# High-priority override for Jlink images
|
||||
if [[ -n "$bundled_jvm" ]]; then
|
||||
echo "$bundled_jvm/bin/java"
|
||||
elif [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then
|
||||
echo "$JAVA_HOME/bin/java"
|
||||
else
|
||||
echo "java"
|
||||
fi
|
||||
}
|
||||
|
||||
echoerr () {
|
||||
echo 1>&2 "$@"
|
||||
}
|
||||
vlog () {
|
||||
[[ $verbose || $debug ]] && echoerr "$@"
|
||||
}
|
||||
dlog () {
|
||||
[[ $debug ]] && echoerr "$@"
|
||||
}
|
||||
execRunner () {
|
||||
# print the arguments one to a line, quoting any containing spaces
|
||||
[[ $verbose || $debug ]] && echo "# Executing command line:" && {
|
||||
for arg; do
|
||||
if printf "%s\n" "$arg" | grep -q ' '; then
|
||||
printf "\"%s\"\n" "$arg"
|
||||
else
|
||||
printf "%s\n" "$arg"
|
||||
fi
|
||||
done
|
||||
echo ""
|
||||
}
|
||||
|
||||
# we use "exec" here for our pids to be accurate.
|
||||
exec "$@"
|
||||
}
|
||||
addJava () {
|
||||
dlog "[addJava] arg = '$1'"
|
||||
java_args+=( "$1" )
|
||||
}
|
||||
addApp () {
|
||||
dlog "[addApp] arg = '$1'"
|
||||
app_commands+=( "$1" )
|
||||
}
|
||||
addResidual () {
|
||||
dlog "[residual] arg = '$1'"
|
||||
residual_args+=( "$1" )
|
||||
}
|
||||
addDebugger () {
|
||||
addJava "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=$1"
|
||||
}
|
||||
|
||||
addKanelaAgent () {
|
||||
addJava "-javaagent:$lib_dir/kanela-agent-1.0.1.jar"
|
||||
}
|
||||
|
||||
require_arg () {
|
||||
local type="$1"
|
||||
local opt="$2"
|
||||
local arg="$3"
|
||||
if [[ -z "$arg" ]] || [[ "${arg:0:1}" == "-" ]]; then
|
||||
die "$opt requires <$type> argument"
|
||||
fi
|
||||
}
|
||||
is_function_defined() {
|
||||
declare -f "$1" > /dev/null
|
||||
}
|
||||
|
||||
# Attempt to detect if the script is running via a GUI or not
|
||||
# TODO - Determine where/how we use this generically
|
||||
detect_terminal_for_ui() {
|
||||
[[ ! -t 0 ]] && [[ "${#residual_args}" == "0" ]] && {
|
||||
echo "true"
|
||||
}
|
||||
# SPECIAL TEST FOR MAC
|
||||
[[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]] && [[ "${#residual_args}" == "0" ]] && {
|
||||
echo "true"
|
||||
}
|
||||
}
|
||||
|
||||
# Processes incoming arguments and places them in appropriate global variables. called by the run method.
|
||||
process_args () {
|
||||
local no_more_snp_opts=0
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--) shift && no_more_snp_opts=1 && break ;;
|
||||
-h|-help) usage; exit 1 ;;
|
||||
-v|-verbose) verbose=1 && shift ;;
|
||||
-d|-debug) debug=1 && shift ;;
|
||||
-no-version-check) no_version_check=1 && shift ;;
|
||||
-mem) echo "!! WARNING !! -mem option is ignored. Please use -J-Xmx and -J-Xms" && shift 2 ;;
|
||||
-with-kanela) addKanelaAgent && shift ;;
|
||||
-jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;;
|
||||
-main) custom_mainclass="$2" && shift 2 ;;
|
||||
-java-home) require_arg path "$1" "$2" && jre=`eval echo $2` && java_cmd="$jre/bin/java" && shift 2 ;;
|
||||
-D*|-agentlib*|-XX*) addJava "$1" && shift ;;
|
||||
-J*) addJava "${1:2}" && shift ;;
|
||||
*) addResidual "$1" && shift ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ no_more_snp_opts ]]; then
|
||||
while [[ $# -gt 0 ]]; do
|
||||
addResidual "$1" && shift
|
||||
done
|
||||
fi
|
||||
|
||||
is_function_defined process_my_args && {
|
||||
myargs=("${residual_args[@]}")
|
||||
residual_args=()
|
||||
process_my_args "${myargs[@]}"
|
||||
}
|
||||
}
|
||||
|
||||
# Actually runs the script.
|
||||
run() {
|
||||
# TODO - check for sane environment
|
||||
|
||||
# process the combined args, then reset "$@" to the residuals
|
||||
process_args "$@"
|
||||
set -- "${residual_args[@]}"
|
||||
argumentCount=$#
|
||||
|
||||
#check for jline terminal fixes on cygwin
|
||||
if is_cygwin; then
|
||||
stty -icanon min 1 -echo > /dev/null 2>&1
|
||||
addJava "-Djline.terminal=jline.UnixTerminal"
|
||||
fi
|
||||
|
||||
# check java version
|
||||
if [[ ! $no_version_check ]]; then
|
||||
java_version_check
|
||||
fi
|
||||
|
||||
if [ -n "$custom_mainclass" ]; then
|
||||
mainclass=("$custom_mainclass")
|
||||
else
|
||||
mainclass=("${app_mainclass[@]}")
|
||||
fi
|
||||
|
||||
# Now we check to see if there are any java opts on the environment. These get listed first, with the script able to override them.
|
||||
if [[ "$JAVA_OPTS" != "" ]]; then
|
||||
java_opts="${JAVA_OPTS}"
|
||||
fi
|
||||
|
||||
execRunner "$java_cmd" \
|
||||
${java_opts[@]} \
|
||||
"${java_args[@]}" \
|
||||
-cp "$(fix_classpath "$app_classpath")" \
|
||||
"${mainclass[@]}" \
|
||||
"${app_commands[@]}" \
|
||||
"${residual_args[@]}"
|
||||
|
||||
local exit_code=$?
|
||||
if is_cygwin; then
|
||||
stty icanon echo > /dev/null 2>&1
|
||||
fi
|
||||
exit $exit_code
|
||||
}
|
||||
|
||||
# Loads a configuration file full of default command line options for this script.
|
||||
loadConfigFile() {
|
||||
cat "$1" | sed $'/^\#/d;s/\r$//'
|
||||
}
|
||||
|
||||
# Now check to see if it's a good enough version
|
||||
java_version_check() {
|
||||
readonly java_version=$("$java_cmd" -version 2>&1 | awk -F '"' '/version/ {print $2}')
|
||||
if [[ "$java_version" == "" ]]; then
|
||||
echo
|
||||
echo No java installations was detected.
|
||||
echo Please go to https://adoptopenjdk.net/?variant=openjdk11&jvmVariant=hotspot and download
|
||||
echo
|
||||
exit 1
|
||||
else
|
||||
local major=$(echo "$java_version" | cut -d'.' -f1)
|
||||
if [[ "$major" -eq "1" ]]; then
|
||||
local major=$(echo "$java_version" | cut -d'.' -f2)
|
||||
fi
|
||||
if [[ "$major" -lt "8" ]]; then
|
||||
echo
|
||||
echo The java installation you have is not up to date, eclair-node-gui requires
|
||||
echo at least version 1.8+ \(version 11 recommended\) buy you have version $java_version
|
||||
echo
|
||||
echo Please go to 'https://adoptopenjdk.net/?variant=openjdk11&jvmVariant=hotspot' and download
|
||||
echo a valid Java Runtime and install before running eclair-node-gui.
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
### ------------------------------- ###
|
||||
### Start of customized settings ###
|
||||
### ------------------------------- ###
|
||||
usage() {
|
||||
cat <<EOM
|
||||
Usage: $script_name [options]
|
||||
|
||||
-h | -help print this message
|
||||
-v | -verbose this runner is chattier
|
||||
-d | -debug enable debug output for the launcher script
|
||||
-no-version-check Don't run the java version check.
|
||||
-main <classname> Define a custom main class
|
||||
-jvm-debug <port> Turn on JVM debugging, open at the given port.
|
||||
-with-kanela Turn on kanela, akka's monitoring agent
|
||||
|
||||
# java version (default: java from PATH, currently $(java -version 2>&1 | grep version))
|
||||
-java-home <path> alternate JAVA_HOME
|
||||
|
||||
# jvm options and output control
|
||||
JAVA_OPTS environment variable, if unset uses "$java_opts"
|
||||
-Dkey=val pass -Dkey=val directly to the java runtime
|
||||
-J-X pass option -X directly to the java runtime
|
||||
(-J is stripped)
|
||||
|
||||
# special option
|
||||
-- To stop parsing built-in commands from the rest of the command-line.
|
||||
e.g.) enabling debug and sending -d as app argument
|
||||
\$ ./start-script -d -- -d
|
||||
|
||||
In the case of duplicated or conflicting options, basically the order above
|
||||
shows precedence: JAVA_OPTS lowest, command line options highest except "--".
|
||||
EOM
|
||||
}
|
||||
|
||||
### ------------------------------- ###
|
||||
### Main script ###
|
||||
### ------------------------------- ###
|
||||
|
||||
declare -a residual_args
|
||||
declare -a java_args
|
||||
declare -a app_commands
|
||||
declare -r real_script_path="$(realpath "$0")"
|
||||
declare -r app_home="$(realpath "$(dirname "$real_script_path")")"
|
||||
declare -r lib_dir="$(realpath "${app_home::-4}/lib")" # {app_home::-4} transforms ../bin in ../
|
||||
declare -a app_mainclass=("fr.acinq.eclair.JavafxBoot")
|
||||
declare -a app_entrypoint=$(ls $lib_dir |grep eclair-node-gui) # TODO: improve this
|
||||
declare -a app_classpath=("$lib_dir:$lib_dir/$app_entrypoint")
|
||||
|
||||
# java_cmd is overrode in process_args when -java-home is used
|
||||
declare java_cmd=$(get_java_cmd)
|
||||
|
||||
# if configuration files exist, prepend their contents to $@ so it can be processed by this runner
|
||||
[[ -f "$script_conf_file" ]] && set -- $(loadConfigFile "$script_conf_file") "$@"
|
||||
|
||||
run "$@"
|
44
eclair-node/modules/assembly.xml
Normal file
44
eclair-node/modules/assembly.xml
Normal file
|
@ -0,0 +1,44 @@
|
|||
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
|
||||
<id>bin</id>
|
||||
<formats>
|
||||
<format>zip</format>
|
||||
</formats>
|
||||
<dependencySets> <!-- include dependencies -->
|
||||
<dependencySet>
|
||||
<outputDirectory>lib</outputDirectory>
|
||||
<useProjectArtifact>true</useProjectArtifact> <!-- include eclair-core -->
|
||||
<unpack>false</unpack>
|
||||
<scope>runtime</scope>
|
||||
</dependencySet>
|
||||
</dependencySets>
|
||||
<fileSets> <!-- Include readme and license -->
|
||||
<fileSet>
|
||||
<directory>../</directory>
|
||||
<includes>
|
||||
<include>README.md</include>
|
||||
<include>LICENSE*</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
<fileSet> <!-- Include the launcher scripts -->
|
||||
<directory>${project.basedir}/src/main/resources</directory>
|
||||
<outputDirectory>bin</outputDirectory>
|
||||
<includes>
|
||||
<include>eclair-node.sh</include>
|
||||
<include>eclair-node.bat</include>
|
||||
</includes>
|
||||
<fileMode>0755</fileMode>
|
||||
<lineEnding>unix</lineEnding>
|
||||
</fileSet>
|
||||
<fileSet> <!-- Include eclair-cli -->
|
||||
<directory>../eclair-core/</directory>
|
||||
<outputDirectory>bin</outputDirectory>
|
||||
<includes>
|
||||
<include>eclair-cli</include>
|
||||
</includes>
|
||||
<fileMode>0755</fileMode>
|
||||
<lineEnding>unix</lineEnding>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</assembly>
|
|
@ -49,25 +49,25 @@
|
|||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.github.chrisdchristo</groupId>
|
||||
<artifactId>capsule-maven-plugin</artifactId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<finalName>${project.name}-${project.version}-${git.commit.id.abbrev}</finalName>
|
||||
<descriptors>
|
||||
<descriptor>modules/assembly.xml</descriptor>
|
||||
</descriptors>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>fr.acinq.eclair.Boot</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<appClass>fr.acinq.eclair.Boot</appClass>
|
||||
<type>fat</type>
|
||||
<fileName>${project.name}-${project.version}</fileName>
|
||||
<fileDesc>-${git.commit.id.abbrev}</fileDesc>
|
||||
<manifest>
|
||||
<entry>
|
||||
<key>Java-Agents</key>
|
||||
<value>kanela-agent-1.0.1.jar</value>
|
||||
</entry>
|
||||
</manifest>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
@ -136,16 +136,6 @@
|
|||
<artifactId>kamon-jdbc_${scala.version.short}</artifactId>
|
||||
<version>${kamon.version}</version>
|
||||
</dependency>
|
||||
<!--dependency>
|
||||
<groupId>io.kamon</groupId>
|
||||
<artifactId>kamon-annotation_${scala.version.short}</artifactId>
|
||||
<version>2.0.0-RC1</version>
|
||||
</dependency-->
|
||||
<!--dependency>
|
||||
<groupId>io.kamon</groupId>
|
||||
<artifactId>kamon-akka-http_${scala.version.short}</artifactId>
|
||||
<version>${kamon.version}</version>
|
||||
</dependency-->
|
||||
<!-- test dependencies -->
|
||||
<dependency>
|
||||
<groupId>com.typesafe.akka</groupId>
|
||||
|
|
192
eclair-node/src/main/resources/eclair-node.bat
Normal file
192
eclair-node/src/main/resources/eclair-node.bat
Normal file
|
@ -0,0 +1,192 @@
|
|||
@REM Copyright (c) 2012, Joshua Suereth
|
||||
@REM All rights reserved.
|
||||
@REM
|
||||
@REM Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
@REM
|
||||
@REM Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
@REM Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
@REM THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@REM @@APP_NAME@@ launcher script
|
||||
@REM
|
||||
@REM Environment:
|
||||
@REM JAVA_HOME - location of a JDK home dir (optional if java on path)
|
||||
@REM CFG_OPTS - JVM options (optional)
|
||||
@REM Configuration:
|
||||
@REM @@APP_ENV_NAME@@_config.txt found in the @@APP_ENV_NAME@@_HOME.
|
||||
@setlocal enabledelayedexpansion
|
||||
@setlocal enableextensions
|
||||
|
||||
@echo off
|
||||
|
||||
|
||||
if "%@@APP_ENV_NAME@@_HOME%"=="" (
|
||||
set "APP_HOME=%~dp0\\.."
|
||||
|
||||
rem Also set the old env name for backwards compatibility
|
||||
set "@@APP_ENV_NAME@@_HOME=%~dp0\\.."
|
||||
) else (
|
||||
set "APP_HOME=%@@APP_ENV_NAME@@_HOME%"
|
||||
)
|
||||
|
||||
set "APP_LIB_DIR=%APP_HOME%\lib\"
|
||||
|
||||
rem Detect if we were double clicked, although theoretically A user could
|
||||
rem manually run cmd /c
|
||||
for %%x in (!cmdcmdline!) do if %%~x==/c set DOUBLECLICKED=1
|
||||
|
||||
rem FIRST we load the config file of extra options.
|
||||
set "CFG_FILE=%APP_HOME%\@@APP_ENV_NAME@@_config.txt"
|
||||
set CFG_OPTS=
|
||||
call :parse_config "%CFG_FILE%" CFG_OPTS
|
||||
|
||||
rem We use the value of the JAVA_OPTS environment variable if defined, rather than the config.
|
||||
set _JAVA_OPTS=%JAVA_OPTS%
|
||||
if "!_JAVA_OPTS!"=="" set _JAVA_OPTS=!CFG_OPTS!
|
||||
|
||||
rem We keep in _JAVA_PARAMS all -J-prefixed and -D-prefixed arguments
|
||||
rem "-J" is stripped, "-D" is left as is, and everything is appended to JAVA_OPTS
|
||||
set _JAVA_PARAMS=
|
||||
set _APP_ARGS=
|
||||
|
||||
for /f %%i in ('dir /b %APP_LIB_DIR%\eclair-node*') do set APP_ENTRYPOINT=%%i
|
||||
set CUSTOM_MAIN_CLASS="fr.acinq.eclair.Boot"
|
||||
set APP_CLASSPATH="%APP_LIB_DIR%;%APP_LIB_DIR%/%APP_ENTRYPOINT%"
|
||||
|
||||
rem Bundled JRE has priority over standard environment variables
|
||||
if defined BUNDLED_JVM (
|
||||
set "_JAVACMD=%BUNDLED_JVM%\bin\java.exe"
|
||||
) else (
|
||||
if "%JAVACMD%" neq "" (
|
||||
set "_JAVACMD=%JAVACMD%"
|
||||
) else (
|
||||
if "%JAVA_HOME%" neq "" (
|
||||
if exist "%JAVA_HOME%\bin\java.exe" set "_JAVACMD=%JAVA_HOME%\bin\java.exe"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if "%_JAVACMD%"=="" set _JAVACMD=java
|
||||
|
||||
rem Detect if this java is ok to use.
|
||||
for /F %%j in ('"%_JAVACMD%" -version 2^>^&1') do (
|
||||
if %%~j==java set JAVAINSTALLED=1
|
||||
if %%~j==openjdk set JAVAINSTALLED=1
|
||||
)
|
||||
|
||||
rem BAT has no logical or, so we do it OLD SCHOOL! Oppan Redmond Style
|
||||
set JAVAOK=true
|
||||
if not defined JAVAINSTALLED set JAVAOK=false
|
||||
|
||||
if "%JAVAOK%"=="false" (
|
||||
echo.
|
||||
echo A Java JDK is not installed or can't be found.
|
||||
if not "%JAVA_HOME%"=="" (
|
||||
echo JAVA_HOME = "%JAVA_HOME%"
|
||||
)
|
||||
echo.
|
||||
echo Please go to
|
||||
echo https://adoptopenjdk.net/?variant=openjdk11&jvmVariant=hotspot
|
||||
echo and download a valid Java JDK and install before running @@APP_NAME@@.
|
||||
echo.
|
||||
echo If you think this message is in error, please check
|
||||
echo your environment variables to see if "java.exe" and "javac.exe" are
|
||||
echo available via JAVA_HOME or PATH.
|
||||
echo.
|
||||
if defined DOUBLECLICKED pause
|
||||
exit /B 1
|
||||
)
|
||||
|
||||
rem if configuration files exist, prepend their contents to the script arguments so it can be processed by this runner
|
||||
call :parse_config "%SCRIPT_CONF_FILE%" SCRIPT_CONF_ARGS
|
||||
|
||||
call :process_args %SCRIPT_CONF_ARGS% %%*
|
||||
|
||||
set _JAVA_OPTS=!_JAVA_OPTS! !_JAVA_PARAMS!
|
||||
|
||||
if defined CUSTOM_MAIN_CLASS (
|
||||
set MAIN_CLASS=!CUSTOM_MAIN_CLASS!
|
||||
) else (
|
||||
set MAIN_CLASS=!APP_MAIN_CLASS!
|
||||
)
|
||||
|
||||
rem Call the application and pass all arguments unchanged.
|
||||
"%_JAVACMD%" !_JAVA_OPTS! !@@APP_ENV_NAME@@_OPTS! -cp %APP_CLASSPATH% %MAIN_CLASS% !_APP_ARGS!
|
||||
|
||||
@endlocal
|
||||
|
||||
exit /B %ERRORLEVEL%
|
||||
|
||||
|
||||
rem Loads a configuration file full of default command line options for this script.
|
||||
rem First argument is the path to the config file.
|
||||
rem Second argument is the name of the environment variable to write to.
|
||||
:parse_config
|
||||
set _PARSE_FILE=%~1
|
||||
set _PARSE_OUT=
|
||||
if exist "%_PARSE_FILE%" (
|
||||
FOR /F "tokens=* eol=# usebackq delims=" %%i IN ("%_PARSE_FILE%") DO (
|
||||
set _PARSE_OUT=!_PARSE_OUT! %%i
|
||||
)
|
||||
)
|
||||
set %2=!_PARSE_OUT!
|
||||
exit /B 0
|
||||
|
||||
|
||||
:add_java
|
||||
set _JAVA_PARAMS=!_JAVA_PARAMS! %*
|
||||
exit /B 0
|
||||
|
||||
|
||||
:add_app
|
||||
set _APP_ARGS=!_APP_ARGS! %*
|
||||
exit /B 0
|
||||
|
||||
|
||||
rem Processes incoming arguments and places them in appropriate global variables
|
||||
:process_args
|
||||
:param_loop
|
||||
call set _PARAM1=%%1
|
||||
set "_TEST_PARAM=%~1"
|
||||
|
||||
if ["!_PARAM1!"]==[""] goto param_afterloop
|
||||
|
||||
|
||||
rem ignore arguments that do not start with '-'
|
||||
if "%_TEST_PARAM:~0,1%"=="-" goto param_java_check
|
||||
set _APP_ARGS=!_APP_ARGS! !_PARAM1!
|
||||
shift
|
||||
goto param_loop
|
||||
|
||||
:param_java_check
|
||||
if "!_TEST_PARAM:~0,2!"=="-J" (
|
||||
rem strip -J prefix
|
||||
set _JAVA_PARAMS=!_JAVA_PARAMS! !_TEST_PARAM:~2!
|
||||
shift
|
||||
goto param_loop
|
||||
)
|
||||
|
||||
if "!_TEST_PARAM:~0,2!"=="-D" (
|
||||
rem test if this was double-quoted property "-Dprop=42"
|
||||
for /F "delims== tokens=1,*" %%G in ("!_TEST_PARAM!") DO (
|
||||
if not ["%%H"] == [""] (
|
||||
set _JAVA_PARAMS=!_JAVA_PARAMS! !_PARAM1!
|
||||
) else if [%2] neq [] (
|
||||
rem it was a normal property: -Dprop=42 or -Drop="42"
|
||||
call set _PARAM1=%%1=%%2
|
||||
set _JAVA_PARAMS=!_JAVA_PARAMS! !_PARAM1!
|
||||
shift
|
||||
)
|
||||
)
|
||||
) else (
|
||||
if "!_TEST_PARAM!"=="-main" (
|
||||
call set CUSTOM_MAIN_CLASS=%%2
|
||||
shift
|
||||
) else (
|
||||
set _APP_ARGS=!_APP_ARGS! !_PARAM1!
|
||||
)
|
||||
)
|
||||
shift
|
||||
goto param_loop
|
||||
:param_afterloop
|
||||
|
||||
exit /B 0
|
360
eclair-node/src/main/resources/eclair-node.sh
Executable file
360
eclair-node/src/main/resources/eclair-node.sh
Executable file
|
@ -0,0 +1,360 @@
|
|||
# Copyright (c) 2012, Joshua Suereth
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
# Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#!/usr/bin/env bash
|
||||
|
||||
### ------------------------------- ###
|
||||
### Helper methods for BASH scripts ###
|
||||
### ------------------------------- ###
|
||||
|
||||
die() {
|
||||
echo "$@" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
realpath () {
|
||||
(
|
||||
TARGET_FILE="$1"
|
||||
CHECK_CYGWIN="$2"
|
||||
|
||||
cd "$(dirname "$TARGET_FILE")"
|
||||
TARGET_FILE=$(basename "$TARGET_FILE")
|
||||
|
||||
COUNT=0
|
||||
while [ -L "$TARGET_FILE" -a $COUNT -lt 100 ]
|
||||
do
|
||||
TARGET_FILE=$(readlink "$TARGET_FILE")
|
||||
cd "$(dirname "$TARGET_FILE")"
|
||||
TARGET_FILE=$(basename "$TARGET_FILE")
|
||||
COUNT=$(($COUNT + 1))
|
||||
done
|
||||
|
||||
if [ "$TARGET_FILE" == "." -o "$TARGET_FILE" == ".." ]; then
|
||||
cd "$TARGET_FILE"
|
||||
TARGET_FILEPATH=
|
||||
else
|
||||
TARGET_FILEPATH=/$TARGET_FILE
|
||||
fi
|
||||
|
||||
# make sure we grab the actual windows path, instead of cygwin's path.
|
||||
if [[ "x$CHECK_CYGWIN" == "x" ]]; then
|
||||
echo "$(pwd -P)/$TARGET_FILE"
|
||||
else
|
||||
echo $(cygwinpath "$(pwd -P)/$TARGET_FILE")
|
||||
fi
|
||||
)
|
||||
}
|
||||
|
||||
# TODO - Do we need to detect msys?
|
||||
|
||||
# Uses uname to detect if we're in the odd cygwin environment.
|
||||
is_cygwin() {
|
||||
local os=$(uname -s)
|
||||
case "$os" in
|
||||
CYGWIN*) return 0 ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# This can fix cygwin style /cygdrive paths so we get the
|
||||
# windows style paths.
|
||||
cygwinpath() {
|
||||
local file="$1"
|
||||
if is_cygwin; then
|
||||
echo $(cygpath -w $file)
|
||||
else
|
||||
echo $file
|
||||
fi
|
||||
}
|
||||
|
||||
# Make something URI friendly
|
||||
make_url() {
|
||||
url="$1"
|
||||
local nospaces=${url// /%20}
|
||||
if is_cygwin; then
|
||||
echo "/${nospaces//\\//}"
|
||||
else
|
||||
echo "$nospaces"
|
||||
fi
|
||||
}
|
||||
|
||||
# This crazy function reads in a vanilla "linux" classpath string (only : are separators, and all /),
|
||||
# and returns a classpath with windows style paths, and ; separators.
|
||||
fixCygwinClasspath() {
|
||||
OLDIFS=$IFS
|
||||
IFS=":"
|
||||
read -a classpath_members <<< "$1"
|
||||
declare -a fixed_members
|
||||
IFS=$OLDIFS
|
||||
for i in "${!classpath_members[@]}"
|
||||
do
|
||||
fixed_members[i]=$(realpath "${classpath_members[i]}" "fix")
|
||||
done
|
||||
IFS=";"
|
||||
echo "${fixed_members[*]}"
|
||||
IFS=$OLDIFS
|
||||
}
|
||||
|
||||
# Fix the classpath we use for cygwin.
|
||||
fix_classpath() {
|
||||
cp="$1"
|
||||
if is_cygwin; then
|
||||
echo "$(fixCygwinClasspath "$cp")"
|
||||
else
|
||||
echo "$cp"
|
||||
fi
|
||||
}
|
||||
# Detect if we should use JAVA_HOME or just try PATH.
|
||||
get_java_cmd() {
|
||||
# High-priority override for Jlink images
|
||||
if [[ -n "$bundled_jvm" ]]; then
|
||||
echo "$bundled_jvm/bin/java"
|
||||
elif [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then
|
||||
echo "$JAVA_HOME/bin/java"
|
||||
else
|
||||
echo "java"
|
||||
fi
|
||||
}
|
||||
|
||||
echoerr () {
|
||||
echo 1>&2 "$@"
|
||||
}
|
||||
vlog () {
|
||||
[[ $verbose || $debug ]] && echoerr "$@"
|
||||
}
|
||||
dlog () {
|
||||
[[ $debug ]] && echoerr "$@"
|
||||
}
|
||||
execRunner () {
|
||||
# print the arguments one to a line, quoting any containing spaces
|
||||
[[ $verbose || $debug ]] && echo "# Executing command line:" && {
|
||||
for arg; do
|
||||
if printf "%s\n" "$arg" | grep -q ' '; then
|
||||
printf "\"%s\"\n" "$arg"
|
||||
else
|
||||
printf "%s\n" "$arg"
|
||||
fi
|
||||
done
|
||||
echo ""
|
||||
}
|
||||
|
||||
# we use "exec" here for our pids to be accurate.
|
||||
exec "$@"
|
||||
}
|
||||
addJava () {
|
||||
dlog "[addJava] arg = '$1'"
|
||||
java_args+=( "$1" )
|
||||
}
|
||||
addApp () {
|
||||
dlog "[addApp] arg = '$1'"
|
||||
app_commands+=( "$1" )
|
||||
}
|
||||
addResidual () {
|
||||
dlog "[residual] arg = '$1'"
|
||||
residual_args+=( "$1" )
|
||||
}
|
||||
addDebugger () {
|
||||
addJava "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=$1"
|
||||
}
|
||||
|
||||
addKanelaAgent () {
|
||||
addJava "-javaagent:$lib_dir/kanela-agent-1.0.1.jar"
|
||||
}
|
||||
|
||||
require_arg () {
|
||||
local type="$1"
|
||||
local opt="$2"
|
||||
local arg="$3"
|
||||
if [[ -z "$arg" ]] || [[ "${arg:0:1}" == "-" ]]; then
|
||||
die "$opt requires <$type> argument"
|
||||
fi
|
||||
}
|
||||
is_function_defined() {
|
||||
declare -f "$1" > /dev/null
|
||||
}
|
||||
|
||||
# Attempt to detect if the script is running via a GUI or not
|
||||
# TODO - Determine where/how we use this generically
|
||||
detect_terminal_for_ui() {
|
||||
[[ ! -t 0 ]] && [[ "${#residual_args}" == "0" ]] && {
|
||||
echo "true"
|
||||
}
|
||||
# SPECIAL TEST FOR MAC
|
||||
[[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]] && [[ "${#residual_args}" == "0" ]] && {
|
||||
echo "true"
|
||||
}
|
||||
}
|
||||
|
||||
# Processes incoming arguments and places them in appropriate global variables. called by the run method.
|
||||
process_args () {
|
||||
local no_more_snp_opts=0
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--) shift && no_more_snp_opts=1 && break ;;
|
||||
-h|-help) usage; exit 1 ;;
|
||||
-v|-verbose) verbose=1 && shift ;;
|
||||
-d|-debug) debug=1 && shift ;;
|
||||
-no-version-check) no_version_check=1 && shift ;;
|
||||
-mem) echo "!! WARNING !! -mem option is ignored. Please use -J-Xmx and -J-Xms" && shift 2 ;;
|
||||
-with-kanela) addKanelaAgent && shift ;;
|
||||
-jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;;
|
||||
-main) custom_mainclass="$2" && shift 2 ;;
|
||||
-java-home) require_arg path "$1" "$2" && jre=`eval echo $2` && java_cmd="$jre/bin/java" && shift 2 ;;
|
||||
-D*|-agentlib*|-XX*) addJava "$1" && shift ;;
|
||||
-J*) addJava "${1:2}" && shift ;;
|
||||
*) addResidual "$1" && shift ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ no_more_snp_opts ]]; then
|
||||
while [[ $# -gt 0 ]]; do
|
||||
addResidual "$1" && shift
|
||||
done
|
||||
fi
|
||||
|
||||
is_function_defined process_my_args && {
|
||||
myargs=("${residual_args[@]}")
|
||||
residual_args=()
|
||||
process_my_args "${myargs[@]}"
|
||||
}
|
||||
}
|
||||
|
||||
# Actually runs the script.
|
||||
run() {
|
||||
# TODO - check for sane environment
|
||||
|
||||
# process the combined args, then reset "$@" to the residuals
|
||||
process_args "$@"
|
||||
set -- "${residual_args[@]}"
|
||||
argumentCount=$#
|
||||
|
||||
#check for jline terminal fixes on cygwin
|
||||
if is_cygwin; then
|
||||
stty -icanon min 1 -echo > /dev/null 2>&1
|
||||
addJava "-Djline.terminal=jline.UnixTerminal"
|
||||
fi
|
||||
|
||||
# check java version
|
||||
if [[ ! $no_version_check ]]; then
|
||||
java_version_check
|
||||
fi
|
||||
|
||||
if [ -n "$custom_mainclass" ]; then
|
||||
mainclass=("$custom_mainclass")
|
||||
else
|
||||
mainclass=("${app_mainclass[@]}")
|
||||
fi
|
||||
|
||||
# Now we check to see if there are any java opts on the environment. These get listed first, with the script able to override them.
|
||||
if [[ "$JAVA_OPTS" != "" ]]; then
|
||||
java_opts="${JAVA_OPTS}"
|
||||
fi
|
||||
|
||||
execRunner "$java_cmd" \
|
||||
${java_opts[@]} \
|
||||
"${java_args[@]}" \
|
||||
-cp "$(fix_classpath "$app_classpath")" \
|
||||
"${mainclass[@]}" \
|
||||
"${app_commands[@]}" \
|
||||
"${residual_args[@]}"
|
||||
|
||||
local exit_code=$?
|
||||
if is_cygwin; then
|
||||
stty icanon echo > /dev/null 2>&1
|
||||
fi
|
||||
exit $exit_code
|
||||
}
|
||||
|
||||
# Loads a configuration file full of default command line options for this script.
|
||||
loadConfigFile() {
|
||||
cat "$1" | sed $'/^\#/d;s/\r$//'
|
||||
}
|
||||
|
||||
# Now check to see if it's a good enough version
|
||||
java_version_check() {
|
||||
readonly java_version=$("$java_cmd" -version 2>&1 | awk -F '"' '/version/ {print $2}')
|
||||
if [[ "$java_version" == "" ]]; then
|
||||
echo
|
||||
echo No java installations was detected.
|
||||
echo Please go to https://adoptopenjdk.net/?variant=openjdk11&jvmVariant=hotspot and download
|
||||
echo
|
||||
exit 1
|
||||
else
|
||||
local major=$(echo "$java_version" | cut -d'.' -f1)
|
||||
if [[ "$major" -eq "1" ]]; then
|
||||
local major=$(echo "$java_version" | cut -d'.' -f2)
|
||||
fi
|
||||
if [[ "$major" -lt "8" ]]; then
|
||||
echo
|
||||
echo The java installation you have is not up to date, eclair-node requires
|
||||
echo at least version 1.8+ \(version 11 recommended\) buy you have version $java_version
|
||||
echo
|
||||
echo Please go to 'https://adoptopenjdk.net/?variant=openjdk11&jvmVariant=hotspot' and download
|
||||
echo a valid Java Runtime and install before running eclair-node.
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
### ------------------------------- ###
|
||||
### Start of customized settings ###
|
||||
### ------------------------------- ###
|
||||
usage() {
|
||||
cat <<EOM
|
||||
Usage: $script_name [options]
|
||||
|
||||
-h | -help print this message
|
||||
-v | -verbose this runner is chattier
|
||||
-d | -debug enable debug output for the launcher script
|
||||
-no-version-check Don't run the java version check.
|
||||
-main <classname> Define a custom main class
|
||||
-jvm-debug <port> Turn on JVM debugging, open at the given port.
|
||||
-with-kanela Turn on kanela, akka's monitoring agent
|
||||
|
||||
# java version (default: java from PATH, currently $(java -version 2>&1 | grep version))
|
||||
-java-home <path> alternate JAVA_HOME
|
||||
|
||||
# jvm options and output control
|
||||
JAVA_OPTS environment variable, if unset uses "$java_opts"
|
||||
-Dkey=val pass -Dkey=val directly to the java runtime
|
||||
-J-X pass option -X directly to the java runtime
|
||||
(-J is stripped)
|
||||
|
||||
# special option
|
||||
-- To stop parsing built-in commands from the rest of the command-line.
|
||||
e.g.) enabling debug and sending -d as app argument
|
||||
\$ ./start-script -d -- -d
|
||||
|
||||
In the case of duplicated or conflicting options, basically the order above
|
||||
shows precedence: JAVA_OPTS lowest, command line options highest except "--".
|
||||
EOM
|
||||
}
|
||||
|
||||
### ------------------------------- ###
|
||||
### Main script ###
|
||||
### ------------------------------- ###
|
||||
|
||||
declare -a residual_args
|
||||
declare -a java_args
|
||||
declare -a app_commands
|
||||
declare -r real_script_path="$(realpath "$0")"
|
||||
declare -r app_home="$(realpath "$(dirname "$real_script_path")")"
|
||||
declare -r lib_dir="$(realpath "${app_home::-4}/lib")" # {app_home::-4} transforms ../bin in ../
|
||||
declare -a app_mainclass=("fr.acinq.eclair.Boot")
|
||||
declare -a app_entrypoint=$(ls $lib_dir |grep eclair-node) # TODO: improve this
|
||||
declare -a app_classpath=("$lib_dir:$lib_dir/$app_entrypoint")
|
||||
|
||||
# java_cmd is overrode in process_args when -java-home is used
|
||||
declare java_cmd=$(get_java_cmd)
|
||||
|
||||
# if configuration files exist, prepend their contents to $@ so it can be processed by this runner
|
||||
[[ -f "$script_conf_file" ]] && set -- $(loadConfigFile "$script_conf_file") "$@"
|
||||
|
||||
run "$@"
|
21
pom.xml
21
pom.xml
|
@ -81,20 +81,31 @@
|
|||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/lib</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.github.chrisdchristo</groupId>
|
||||
<artifactId>capsule-maven-plugin</artifactId>
|
||||
<version>1.5.1</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<inherited>true</inherited>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>versions-maven-plugin</artifactId>
|
||||
|
|
Loading…
Add table
Reference in a new issue