Compare commits

...

9 Commits

Author SHA1 Message Date
arowser
cffbfb8747 only static link sqlite/gmp/zlib 2018-12-20 13:24:10 +09:00
arowser
526141048f support static link 2018-12-20 13:24:10 +09:00
nicolas.dorier
858f26d52a Configure Static linking for the docker file 2018-12-20 13:24:10 +09:00
nicolas.dorier
3e1fee0f9b Cross compile for arm32 2018-12-20 13:24:10 +09:00
nicolas.dorier
e448b5fd53 Add ARM32 support 2018-12-20 13:24:10 +09:00
nicolas.dorier
8c35509566 circleci support 2018-12-20 13:24:10 +09:00
nicolas.dorier
246ddccfe5 Adapt Dockerfile for BTCPay deployment 2018-12-20 13:24:10 +09:00
nicolas.dorier
bda645007b [Docker] Make sure lightningd receives SIGTERM 2018-12-20 13:24:10 +09:00
Mark Beckwith
e261ec9cdf Handle SIGINT and SIGTERM for PID 1
Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-12-20 13:24:10 +09:00
10 changed files with 419 additions and 3 deletions

119
.circleci/config.yml Normal file
View File

@ -0,0 +1,119 @@
version: 2
jobs:
# publish jobs require $DOCKERHUB_REPO, $DOCKERHUB_USER, $DOCKERHUB_PASS defined
publish_docker_linuxamd64:
machine:
docker_layer_caching: true
steps:
- checkout
- run:
command: |
LATEST_TAG=${CIRCLE_TAG:8} #trim "basedon-" from tag
#
sudo docker build --pull -t $DOCKERHUB_REPO:$LATEST_TAG-amd64 -f Dockerfile .
sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS
sudo docker push $DOCKERHUB_REPO:$LATEST_TAG-amd64
publish_docker_linuxarm32v7:
machine:
docker_layer_caching: true
steps:
- checkout
- run:
command: |
LATEST_TAG=${CIRCLE_TAG:8} #trim "basedon-" from tag
# Make sure the builder is copy the arm emulator
sudo docker run --rm --privileged multiarch/qemu-user-static:register --reset
sed -i -e 's/#EnableQEMU //g' "linuxarm32v7.Dockerfile"
#
sudo docker build --pull -t $DOCKERHUB_REPO:$LATEST_TAG-arm32v7 -f linuxarm32v7.Dockerfile .
sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS
sudo docker push $DOCKERHUB_REPO:$LATEST_TAG-arm32v7
publish_docker_dev:
machine:
docker_layer_caching: true
steps:
- checkout
- run:
command: |
LATEST_TAG=${CIRCLE_TAG:8} #trim "basedon-" from tag
#
sudo docker build --build-arg "DEVELOPER=1" --build-arg "TRACE_TOOLS=false" -t "$DOCKERHUB_REPO:$LATEST_TAG-dev" .
sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS
sudo docker push $DOCKERHUB_REPO:$LATEST_TAG-dev
publish_docker_bench:
machine:
docker_layer_caching: true
steps:
- checkout
- run:
command: |
LATEST_TAG=${CIRCLE_TAG:8} #trim "basedon-" from tag
#
sudo docker build --build-arg "DEVELOPER=1" --build-arg "TRACE_TOOLS=true" -t "$DOCKERHUB_REPO:$LATEST_TAG-bench" .
sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS
sudo docker push $DOCKERHUB_REPO:$LATEST_TAG-bench
publish_docker_multiarch:
machine:
enabled: true
image: circleci/classic:201808-01
steps:
- run:
command: |
# Turn on Experimental features
sudo mkdir $HOME/.docker
sudo sh -c 'echo "{ \"experimental\": \"enabled\" }" >> $HOME/.docker/config.json'
#
sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS
#
LATEST_TAG=${CIRCLE_TAG:8} #trim "basedon-" from tag
sudo docker manifest create --amend $DOCKERHUB_REPO:$LATEST_TAG $DOCKERHUB_REPO:$LATEST_TAG-amd64 $DOCKERHUB_REPO:$LATEST_TAG-arm32v7
sudo docker manifest annotate $DOCKERHUB_REPO:$LATEST_TAG $DOCKERHUB_REPO:$LATEST_TAG-amd64 --os linux --arch amd64
sudo docker manifest annotate $DOCKERHUB_REPO:$LATEST_TAG $DOCKERHUB_REPO:$LATEST_TAG-arm32v7 --os linux --arch arm --variant v7
sudo docker manifest push $DOCKERHUB_REPO:$LATEST_TAG -p
workflows:
version: 2
publish:
jobs:
- publish_docker_linuxamd64:
filters:
# ignore any commit on any branch by default
branches:
ignore: /.*/
# only act on version tags
tags:
only: /basedon-.+/
- publish_docker_linuxarm32v7:
filters:
# ignore any commit on any branch by default
branches:
ignore: /.*/
# only act on version tags
tags:
only: /basedon-.+/
- publish_docker_dev:
filters:
# ignore any commit on any branch by default
branches:
ignore: /.*/
# only act on version tags
tags:
only: /basedon-.+/
- publish_docker_bench:
filters:
# ignore any commit on any branch by default
branches:
ignore: /.*/
# only act on version tags
tags:
only: /basedon-.+/
- publish_docker_multiarch:
requires:
- publish_docker_linuxamd64
- publish_docker_linuxarm32v7
filters:
branches:
ignore: /.*/
tags:
only: /basedon-.+/

3
.dockerignore Normal file
View File

@ -0,0 +1,3 @@
Dockerfile
linuxarm32v7.Dockerfile
.circleci/config.yml

1
.gitattributes vendored
View File

@ -4,3 +4,4 @@
Makefile text eol=lf
configure text eol=lf
.gitmodules text eol=lf
hooks/build text eol=lf

View File

@ -61,7 +61,21 @@ COPY . .
ARG DEVELOPER=0
RUN ./configure && make -j3 DEVELOPER=${DEVELOPER} && cp lightningd/lightning* cli/lightning-cli /usr/bin/
FROM alpine:3.7
# This is a manifest image, will pull the image with the same arch as the builder machine
FROM microsoft/dotnet:2.1.500-sdk AS dotnetbuilder
RUN apt-get -y update && apt-get -y install git
WORKDIR /source
RUN git clone https://github.com/dgarage/NBXplorer && cd NBXplorer && git checkout v2.0.0.2
# Cache some dependencies
RUN cd NBXplorer/NBXplorer.NodeWaiter && dotnet restore && cd ..
RUN cd NBXplorer/NBXplorer.NodeWaiter && \
dotnet publish --output /app/ --configuration Release
FROM microsoft/dotnet:2.1.5-runtime-alpine3.7
RUN apk add --no-cache \
gmp-dev \
@ -71,9 +85,16 @@ RUN apk add --no-cache \
bash \
zlib-dev
ARG TRACE_TOOLS=false
ENV TRACE_TOOLS=$TRACE_TOOLS
ENV GLIBC_VERSION 2.27-r0
ENV GLIBC_SHA256 938bceae3b83c53e7fa9cc4135ce45e04aae99256c5e74cf186c794b97473bc7
ENV GLIBCBIN_SHA256 3a87874e57b9d92e223f3e90356aaea994af67fb76b71bb72abfb809e948d0d6
ENV TRACE_LOCATION=/opt/traces
VOLUME /opt/traces
# Download and install glibc (https://github.com/jeanblanchard/docker-alpine-glibc/blob/master/Dockerfile)
RUN apk add --update curl && \
curl -Lo /etc/apk/keys/sgerrand.rsa.pub https://github.com/sgerrand/alpine-pkg-glibc/releases/download/$GLIBC_VERSION/sgerrand.rsa.pub && \
@ -84,18 +105,32 @@ RUN apk add --update curl && \
apk add glibc-bin.apk glibc.apk && \
/usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib && \
echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf && \
( ! $TRACE_TOOLS || \
( \
sed -i -e 's/v[[:digit:]]\.[[:digit:]]/edge/g' /etc/apk/repositories && \
echo "http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
apk add --no-cache perf perl && \
mkdir FlameGraph && cd FlameGraph && \
curl -Lo FlameGraph.tar.gz "https://github.com/brendangregg/FlameGraph/archive/v1.0.tar.gz" && \
tar -zxvf FlameGraph.tar.gz --strip-components=1 && rm FlameGraph.tar.gz && cd .. \
) \
) && \
apk del curl && \
rm -rf glibc.apk glibc-bin.apk /var/cache/apk/*
ENV LIGHTNINGD_DATA=/root/.lightning
ENV LIGHTNINGD_RPC_PORT=9835
RUN mkdir $LIGHTNINGD_DATA && \
touch $LIGHTNINGD_DATA/config
VOLUME [ "/root/.lightning" ]
COPY --from=builder /opt/lightningd/cli/lightning-cli /usr/bin
COPY --from=builder /opt/lightningd/lightningd/lightning* /usr/bin/
COPY --from=builder /opt/bitcoin/bin /usr/bin
COPY --from=builder /opt/litecoin/bin /usr/bin
COPY --from=dotnetbuilder /app /opt/NBXplorer.NodeWaiter
COPY tools/docker-entrypoint.sh entrypoint.sh
EXPOSE 9735 9835

View File

@ -180,7 +180,11 @@ CFLAGS = $(CPPFLAGS) $(CWARNFLAGS) $(CDEBUGFLAGS) -I $(CCANDIR) $(EXTERNAL_INCLU
CONFIGURATOR_CC := $(CC)
LDFLAGS = $(PIE_LDFLAGS)
ifeq ($(STATIC),1)
LDLIBS = -L/usr/local/lib -Wl,-dn -lgmp -lsqlite3 -lz -Wl,-dy -lm -lpthread -ldl $(COVFLAGS)
else
LDLIBS = -L/usr/local/lib -lm -lgmp -lsqlite3 -lz $(COVFLAGS)
endif
default: all-programs all-test-programs

View File

@ -122,6 +122,24 @@ volumes:
clightning_bitcoin_datadir:
```
Alternatively you can use `LIGHTNINGD_OPT`:
```
clightning_bitcoin:
image: elementsproject/lightningd
environment:
EXPOSE_TCP: "true"
LIGHTNINGD_OPT: |
bitcoin-rpcconnect=bitcoind
bitcoin-rpcuser=rpcuser
bitcoin-rpcpassword=rpcpass
network=testnet
alias=myawesomenode
log-level=debug
```
To select the blockchain you are running LND on, you can alternatively use `LIGHTNINGD_CHAIN` with value `ltc` or `btc` and `LIGHTNINGD_NETWORK` with values `mainnet`, `testnet` or `regtest`).
### Starting `lightningd`
In order to start `lightningd` you will need to have a local `bitcoind`

6
configure vendored
View File

@ -11,6 +11,7 @@ CDEBUGFLAGS=${CDEBUGFLAGS:--std=gnu11 -g -fstack-protector}
DEVELOPER=${DEVELOPER:-0}
EXPERIMENTAL_FEATURES=${EXPERIMENTAL_FEATURES:-0}
COMPAT=${COMPAT:-1}
STATIC=${STATIC:-0}
CONFIGURATOR_CC=${CONFIGURATOR_CC:-$CC}
CONFIGURATOR=ccan/tools/configurator/configurator
@ -54,6 +55,8 @@ usage()
echo " Compatibility mode, good to disable to see if your software breaks"
usage_with_default "--enable/disable-valgrind" "(autodetect)"
echo " Valgrind binary to use for tests"
usage_with_default "--enable/disable-static" "$STATIC" "enable" "disable"
echo " Static link binary"
exit 1
}
@ -110,6 +113,8 @@ for opt in "$@"; do
--disable-compat) COMPAT=0;;
--enable-valgrind) VALGRIND=1;;
--disable-valgrind) VALGRIND=0;;
--enable-static) STATIC=1;;
--disable-static) STATIC=0;;
--help|-h) usage;;
*)
echo "Unknown option '$opt'" >&2
@ -144,6 +149,7 @@ add_var DEVELOPER "$DEVELOPER" $CONFIG_HEADER
add_var EXPERIMENTAL_FEATURES "$EXPERIMENTAL_FEATURES" $CONFIG_HEADER
add_var COMPAT "$COMPAT" $CONFIG_HEADER
add_var PYTEST "$PYTEST"
add_var STATIC "$STATIC"
# Hack to avoid sha256 name clash with libwally: will be fixed when that
# becomes a standalone shared lib.

View File

@ -573,6 +573,38 @@ void notify_new_block(struct lightningd *ld, u32 block_height)
channel_notify_new_block(ld, block_height);
}
static void on_sigint(int _ UNUSED)
{
static const char *msg = "lightningd: SIGINT caught, exiting.\n";
write(STDERR_FILENO, msg, strlen(msg));
_exit(1);
}
static void on_sigterm(int _ UNUSED)
{
static const char *msg = "lightningd: SIGTERM caught, exiting.\n";
write(STDERR_FILENO, msg, strlen(msg));
_exit(1);
}
/*~ We only need to handle SIGTERM and SIGINT for the case we are PID 1 of
* docker container since Linux makes special this PID and requires that
* some handler exist. */
static void setup_sig_handlers(void)
{
struct sigaction sigint, sigterm;
memset(&sigint, 0, sizeof(struct sigaction));
memset(&sigterm, 0, sizeof(struct sigaction));
sigint.sa_handler = on_sigint;
sigterm.sa_handler = on_sigterm;
if (1 == getpid()) {
sigaction(SIGINT, &sigint, NULL);
sigaction(SIGTERM, &sigterm, NULL);
}
}
int main(int argc, char *argv[])
{
struct lightningd *ld;
@ -581,6 +613,9 @@ int main(int argc, char *argv[])
/*~ What happens in strange locales should stay there. */
setup_locale();
setup_sig_handlers();
/*~ Every daemon calls this in some form: the hooks are for dumping
* backtraces when we crash (if supported on this platform). */
daemon_setup(argv[0], log_backtrace_print, log_backtrace_exit);

115
linuxarm32v7.Dockerfile Normal file
View File

@ -0,0 +1,115 @@
FROM debian:stretch-slim as downloader
RUN set -ex \
&& apt-get update \
&& apt-get install -qq --no-install-recommends ca-certificates dirmngr wget \
qemu qemu-user-static qemu-user binfmt-support
WORKDIR /opt
ARG BITCOIN_VERSION=0.17.0
ENV BITCOIN_TARBALL bitcoin-$BITCOIN_VERSION-arm-linux-gnueabihf.tar.gz
ENV BITCOIN_URL https://bitcoincore.org/bin/bitcoin-core-$BITCOIN_VERSION/$BITCOIN_TARBALL
ENV BITCOIN_ASC_URL https://bitcoincore.org/bin/bitcoin-core-$BITCOIN_VERSION/SHA256SUMS.asc
RUN mkdir /opt/bitcoin && cd /opt/bitcoin \
&& wget -qO $BITCOIN_TARBALL "$BITCOIN_URL" \
&& wget -qO bitcoin.asc "$BITCOIN_ASC_URL" \
&& grep $BITCOIN_TARBALL bitcoin.asc | tee SHA256SUMS.asc \
&& sha256sum -c SHA256SUMS.asc \
&& BD=bitcoin-$BITCOIN_VERSION/bin \
&& tar -xzvf $BITCOIN_TARBALL $BD/bitcoin-cli --strip-components=1 \
&& rm $BITCOIN_TARBALL
ENV LITECOIN_VERSION 0.14.2
ENV LITECOIN_TARBALL litecoin-$LITECOIN_VERSION-arm-linux-gnueabihf.tar.gz
ENV LITECOIN_URL https://download.litecoin.org/litecoin-$LITECOIN_VERSION/linux/$LITECOIN_TARBALL
ENV LITECOIN_SHA256 e79f2a8e8e1b9920d07cff8482237b56aa4be2623103d3d2825ce09a2cc2f6d7
# install litecoin binaries
RUN mkdir /opt/litecoin && cd /opt/litecoin \
&& wget -qO litecoin.tar.gz "$LITECOIN_URL" \
&& echo "$LITECOIN_SHA256 litecoin.tar.gz" | sha256sum -c - \
&& BD=litecoin-$LITECOIN_VERSION/bin \
&& tar -xzvf litecoin.tar.gz $BD/litecoin-cli --strip-components=1 --exclude=*-qt \
&& rm litecoin.tar.gz
FROM debian:stretch-slim as builder
ENV LIGHTNINGD_VERSION=master
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates autoconf automake build-essential git libtool python python3 wget gnupg dirmngr git \
libc6-armhf-cross gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
ENV target_host=arm-linux-gnueabihf
ENV AR=${target_host}-ar \
AS=${target_host}-as \
CC=${target_host}-gcc \
CXX=${target_host}-g++ \
LD=${target_host}-ld \
STRIP=${target_host}-strip \
QEMU_LD_PREFIX=/usr/${target_host} \
HOST=${target_host}
RUN wget -q https://zlib.net/zlib-1.2.11.tar.gz \
&& tar xvf zlib-1.2.11.tar.gz \
&& cd zlib-1.2.11 \
&& ./configure --prefix=$QEMU_LD_PREFIX \
&& make \
&& make install && cd .. && rm zlib-1.2.11.tar.gz && rm -rf zlib-1.2.11
RUN apt-get install -y --no-install-recommends unzip tclsh \
&& wget -q https://www.sqlite.org/2018/sqlite-src-3260000.zip \
&& unzip sqlite-src-3260000.zip \
&& cd sqlite-src-3260000 \
&& ./configure --enable-static --disable-readline --disable-threadsafe --disable-load-extension --host=${target_host} --prefix=$QEMU_LD_PREFIX \
&& make \
&& make install && cd .. && rm sqlite-src-3260000.zip && rm -rf sqlite-src-3260000
RUN wget -q https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz \
&& tar xvf gmp-6.1.2.tar.xz \
&& cd gmp-6.1.2 \
&& ./configure --disable-assembly --prefix=$QEMU_LD_PREFIX --host=${target_host} \
&& make \
&& make install && cd .. && rm gmp-6.1.2.tar.xz && rm -rf gmp-6.1.2
COPY --from=downloader /usr/bin/qemu-arm-static /usr/bin/qemu-arm-static
WORKDIR /opt/lightningd
COPY . .
ARG DEVELOPER=0
RUN ./configure --enable-static && make -j3 DEVELOPER=${DEVELOPER} && cp lightningd/lightning* cli/lightning-cli /usr/bin/
# This is a manifest image, will pull the image with the same arch as the builder machine
FROM microsoft/dotnet:2.1.500-sdk AS dotnetbuilder
RUN apt-get -y update && apt-get -y install git
WORKDIR /source
RUN git clone https://github.com/dgarage/NBXplorer && cd NBXplorer && git checkout v2.0.0.2
# Cache some dependencies
RUN cd NBXplorer/NBXplorer.NodeWaiter && dotnet restore && cd ..
RUN cd NBXplorer/NBXplorer.NodeWaiter && \
dotnet publish --output /app/ --configuration Release
FROM microsoft/dotnet:2.1.6-runtime-stretch-slim-arm32v7 as final
COPY --from=downloader /usr/bin/qemu-arm-static /usr/bin/qemu-arm-static
RUN apt-get update && apt-get install -y --no-install-recommends socat inotify-tools \
&& rm -rf /var/lib/apt/lists/*
ENV LIGHTNINGD_DATA=/root/.lightning
ENV LIGHTNINGD_PORT=9835
RUN mkdir $LIGHTNINGD_DATA && \
touch $LIGHTNINGD_DATA/config
VOLUME [ "/root/.lightning" ]
COPY --from=builder /opt/lightningd/cli/lightning-cli /usr/bin
COPY --from=builder /opt/lightningd/lightningd/lightning* /usr/bin/
COPY --from=downloader /opt/bitcoin/bin /usr/bin
COPY --from=downloader /opt/litecoin/bin /usr/bin
COPY --from=dotnetbuilder /app /opt/NBXplorer.NodeWaiter
COPY tools/docker-entrypoint.sh entrypoint.sh
EXPOSE 9735 9835
ENTRYPOINT [ "./entrypoint.sh" ]

View File

@ -2,10 +2,90 @@
: "${EXPOSE_TCP:=false}"
cat <<-EOF > "$LIGHTNINGD_DATA/config"
${LIGHTNINGD_OPT}
EOF
: "${EXPOSE_TCP:=false}"
NETWORK=$(sed -n 's/^network=\(.*\)$/\1/p' < "$LIGHTNINGD_DATA/config")
CHAIN=$(sed -n 's/^chain=\(.*\)$/\1/p' < "$LIGHTNINGD_DATA/config")
sed -i '/^chain=/d' "$LIGHTNINGD_DATA/config"
if [[ ! $LIGHTNINGD_CHAIN ]]; then
CHAIN=$LIGHTNINGD_CHAIN
fi
if [[ ! $LIGHTNINGD_NETWORK ]]; then
NETWORK=$LIGHTNINGD_NETWORK
fi
REPLACEDNETWORK="";
if [ "$CHAIN" == "btc" ]; then
if [ "$NETWORK" == "mainnet" ]; then
REPLACEDNETWORK="bitcoin"
fi
fi
if [ "$CHAIN" == "ltc" ]; then
if [ "$NETWORK" == "mainnet" ]; then
REPLACEDNETWORK="litecoin"
fi
if [ "$NETWORK" == "testnet" ]; then
REPLACEDNETWORK="litecoin-testnet"
fi
if [ "$NETWORK" == "regtest" ]; then
echo "REGTEST NOT AVAILABLE FOR LTC"
exit
fi
fi
if [[ $LIGHTNINGD_EXPLORERURL && $NETWORK && $CHAIN ]]; then
# We need to do that because clightning behave weird if it starts at same time as bitcoin core, or if the node is not synched
echo "Waiting for the node to start and sync"
dotnet /opt/NBXplorer.NodeWaiter/NBXplorer.NodeWaiter.dll --chains "$CHAIN" --network "$NETWORK" --explorerurl "$LIGHTNINGD_EXPLORERURL"
echo "Node synched"
fi
if [[ $TRACE_TOOLS == "true" ]]; then
echo "Trace tools detected, installing sample.sh..."
echo 0 > /proc/sys/kernel/kptr_restrict
echo "
# This script will take one minute of stacktrace samples and plot it in a flamegraph
LIGHTNING_PROCESSES=\$(pidof lightningd lightning_chann lightning_closi lightning_gossi lightning_hsmd lightning_oncha lightning_openi lightning_hsmd lightning_gossipd lightning_channeld | sed -e 's/\s/,/g')
perf record -F 99 -g -a --pid \$LIGHTNING_PROCESSES -o \"$TRACE_LOCATION/perf.data\" -- sleep 60
perf script -i \"$TRACE_LOCATION/perf.data\" > \"$TRACE_LOCATION/output.trace\"
cd /FlameGraph
./stackcollapse-perf.pl \"$TRACE_LOCATION/output.trace\" > \"$TRACE_LOCATION/output.trace.folded\"
svg=\"$TRACE_LOCATION/\$((\$SECONDS / 60))min.svg\"
./flamegraph.pl \"$TRACE_LOCATION/output.trace.folded\" > \"\$svg\"
rm \"$TRACE_LOCATION/perf.data\"
rm \"$TRACE_LOCATION/output.trace\"
rm \"$TRACE_LOCATION/output.trace.folded\"
echo \"flamegraph taken: \$svg\"
" > /usr/bin/sample.sh
chmod +x /usr/bin/sample.sh
echo "
# This script will run sample.sh after 2 min then every 10 minutes
sleep 120
sample.sh
while true; do
sleep 300
. sample.sh
done
" > /usr/bin/sample-loop.sh
chmod +x /usr/bin/sample-loop.sh
fi
if [[ $REPLACEDNETWORK ]]; then
sed -i '/^network=/d' "$LIGHTNINGD_DATA/config"
echo "network=$REPLACEDNETWORK" >> "$LIGHTNINGD_DATA/config"
echo "Replaced network $NETWORK by $REPLACEDNETWORK in $LIGHTNINGD_DATA/config"
fi
if [ "$EXPOSE_TCP" == "true" ]; then
set -m
lightningd "$@" &
echo "C-Lightning starting"
while read -r i; do if [ "$i" = "lightning-rpc" ]; then break; fi; done \
< <(inotifywait -e create,open --format '%f' --quiet "$LIGHTNINGD_DATA" --monitor)
@ -15,5 +95,5 @@ if [ "$EXPOSE_TCP" == "true" ]; then
socat "TCP4-listen:$LIGHTNINGD_RPC_PORT,fork,reuseaddr" "UNIX-CONNECT:$LIGHTNINGD_DATA/lightning-rpc" &
fg %-
else
lightningd "$@"
exec lightningd "$@"
fi