diff --git a/.gitignore b/.gitignore index 8183e4f1..34c02e69 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ terraform/.terraform terraform/.terraform/environment terraform/*.tfstate.backup terraform/*.tfstate +*~ diff --git a/Dockerfile b/Dockerfile index dbd249aa..8386a7fe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ COPY --from=build /root/.nvm /root/.nvm RUN apt-get -yqq update \ && apt-get -yqq upgrade \ - && apt-get -yqq install nginx tor git curl pkg-config libcairo2-dev libjpeg-dev libgif-dev build-essential libpixman-1-dev runit python procps + && apt-get -yqq install nginx tor git curl pkg-config libcairo2-dev libjpeg-dev libgif-dev build-essential libpixman-1-dev runit python procps socat RUN mkdir -p /srv/explorer/static diff --git a/contrib/runits/bitcoin_for_liquid-log-config.runit b/contrib/runits/bitcoin_for_liquid-log-config.runit new file mode 100644 index 00000000..23d9238b --- /dev/null +++ b/contrib/runits/bitcoin_for_liquid-log-config.runit @@ -0,0 +1,2 @@ +u127.0.0.1:23394 +p1- diff --git a/contrib/runits/bitcoin_for_liquid-log.runit b/contrib/runits/bitcoin_for_liquid-log.runit new file mode 100755 index 00000000..07375a08 --- /dev/null +++ b/contrib/runits/bitcoin_for_liquid-log.runit @@ -0,0 +1,2 @@ +#!/bin/sh +exec svlogd /data/logs/bitcoin diff --git a/contrib/runits/electrs-log-config.runit b/contrib/runits/electrs-log-config.runit new file mode 100644 index 00000000..45b56ef1 --- /dev/null +++ b/contrib/runits/electrs-log-config.runit @@ -0,0 +1,2 @@ +u127.0.0.1:23394 +p2- diff --git a/contrib/runits/electrs-log.runit b/contrib/runits/electrs-log.runit new file mode 100755 index 00000000..0f49aecc --- /dev/null +++ b/contrib/runits/electrs-log.runit @@ -0,0 +1,2 @@ +#!/bin/sh +exec svlogd /data/logs/electrs diff --git a/contrib/runits/nginx-log-config.runit b/contrib/runits/nginx-log-config.runit new file mode 100644 index 00000000..0084d696 --- /dev/null +++ b/contrib/runits/nginx-log-config.runit @@ -0,0 +1,2 @@ +u127.0.0.1:23394 +p3- diff --git a/contrib/runits/nginx-log.runit b/contrib/runits/nginx-log.runit new file mode 100755 index 00000000..5c9f1d36 --- /dev/null +++ b/contrib/runits/nginx-log.runit @@ -0,0 +1,2 @@ +#!/bin/sh +exec svlogd /data/logs/nginx diff --git a/contrib/runits/nodedaemon-log-config.runit b/contrib/runits/nodedaemon-log-config.runit new file mode 100644 index 00000000..7eab593f --- /dev/null +++ b/contrib/runits/nodedaemon-log-config.runit @@ -0,0 +1,2 @@ +u127.0.0.1:23394 +p4- diff --git a/contrib/runits/nodedaemon-log.runit b/contrib/runits/nodedaemon-log.runit new file mode 100755 index 00000000..b870d7ab --- /dev/null +++ b/contrib/runits/nodedaemon-log.runit @@ -0,0 +1,2 @@ +#!/bin/sh +exec svlogd /data/logs/nodedaemon diff --git a/contrib/runits/prerenderer-log-config.runit b/contrib/runits/prerenderer-log-config.runit new file mode 100644 index 00000000..5bf873b0 --- /dev/null +++ b/contrib/runits/prerenderer-log-config.runit @@ -0,0 +1,2 @@ +u127.0.0.1:23394 +p5- diff --git a/contrib/runits/prerenderer-log.runit b/contrib/runits/prerenderer-log.runit new file mode 100755 index 00000000..7427e583 --- /dev/null +++ b/contrib/runits/prerenderer-log.runit @@ -0,0 +1,2 @@ +#!/bin/sh +exec svlogd /data/logs/prerenderer diff --git a/contrib/runits/socat.runit b/contrib/runits/socat.runit new file mode 100755 index 00000000..0c754389 --- /dev/null +++ b/contrib/runits/socat.runit @@ -0,0 +1,3 @@ +#!/bin/sh -e + +exec socat UDP-RECV:23394 stderr diff --git a/contrib/runits/tor-log-config.runit b/contrib/runits/tor-log-config.runit new file mode 100644 index 00000000..e7c1e72e --- /dev/null +++ b/contrib/runits/tor-log-config.runit @@ -0,0 +1,2 @@ +u127.0.0.1:23394 +p6- diff --git a/contrib/runits/tor-log.runit b/contrib/runits/tor-log.runit new file mode 100755 index 00000000..571129e8 --- /dev/null +++ b/contrib/runits/tor-log.runit @@ -0,0 +1,2 @@ +#!/bin/sh +exec svlogd /data/logs/tor diff --git a/run.sh b/run.sh index f8368d5f..33a5630d 100755 --- a/run.sh +++ b/run.sh @@ -21,8 +21,14 @@ STATIC_DIR=/srv/explorer/static/$FLAVOR ELECTRS_NETWORK=${NETWORK} -mkdir -p /etc/service/tor +mkdir -p /etc/service/tor/log +mkdir -p /data/logs/tor cp /srv/explorer/source/contrib/runits/tor.runit /etc/service/tor/run +cp /srv/explorer/source/contrib/runits/tor-log.runit /etc/service/tor/log/run +cp /srv/explorer/source/contrib/runits/tor-log-config.runit /data/logs/tor/config + +mkdir -p /etc/service/socat +cp /srv/explorer/source/contrib/runits/socat.runit /etc/service/socat/run NGINX_NOSLASH_PATH="unused" NGINX_REWRITE_NOJS='return 301 " /nojs$uri"' @@ -71,10 +77,17 @@ function preprocess(){ } if [ "$MODE" == "explorer" ]; then - mkdir -p /etc/service/prerenderer /etc/service/nginx /etc/service/electrs + mkdir -p /etc/service/prerenderer/log /etc/service/nginx/log /etc/service/electrs/log + mkdir -p /data/logs/prerenderer /data/logs/nginx /data/logs/electrs preprocess /srv/explorer/source/contrib/runits/electrs.runit /etc/service/electrs/run + cp /srv/explorer/source/contrib/runits/electrs-log.runit /etc/service/electrs/log/run + cp /srv/explorer/source/contrib/runits/electrs-log-config.runit /data/logs/electrs/config cp /srv/explorer/source/contrib/runits/nginx.runit /etc/service/nginx/run + cp /srv/explorer/source/contrib/runits/nginx-log.runit /etc/service/nginx/log/run + cp /srv/explorer/source/contrib/runits/nginx-log-config.runit /data/logs/nginx/config preprocess /srv/explorer/source/contrib/runits/prerenderer.runit /etc/service/prerenderer/run + cp /srv/explorer/source/contrib/runits/prerenderer-log.runit /etc/service/prerenderer/log/run + cp /srv/explorer/source/contrib/runits/prerenderer-log-config.runit /data/logs/prerenderer/config chmod +x /etc/service/prerenderer/run /etc/service/electrs/run elif [ "$MODE" != "private-bridge" ] && [ "$MODE" != "public-bridge" ]; then echo "Mode can only be private-bridge, public-bridge or explorer" @@ -84,9 +97,12 @@ fi preprocess /srv/explorer/source/contrib/${DAEMON}-${NETWORK}-${MODE}.conf.in /data/.${DAEMON}.conf if [ "${DAEMON}" == "liquid" ]; then - mkdir -p /etc/service/bitcoin + mkdir -p /etc/service/bitcoin/log + mkdir -p /data/logs/bitcoin preprocess /srv/explorer/source/contrib/bitcoin-mainnet-pruned-for-liquid.conf.in /data/.bitcoin.conf cp /srv/explorer/source/contrib/runits/bitcoin_for_liquid.runit /etc/service/bitcoin/run + cp /srv/explorer/source/contrib/runits/bitcoin_for_liquid-log.runit /etc/service/bitcoin/log/run + cp /srv/explorer/source/contrib/runits/bitcoin_for_liquid-log-config.runit /data/logs/bitcoin/config fi if [ -f /data/public_nodes ]; then @@ -125,8 +141,11 @@ if [ ! -d /data/logs ]; then mkdir -p /data/logs /data/${DAEMON} /data/bitcoin fi -mkdir -p /etc/service/${DAEMON} +mkdir -p /etc/service/${DAEMON}/log +mkdir -p /data/logs/nodedaemon preprocess /srv/explorer/source/contrib/runits/nodedaemon.runit /etc/service/${DAEMON}/run +cp /srv/explorer/source/contrib/runits/nodedaemon-log.runit /etc/service/${DAEMON}/log/run +cp /srv/explorer/source/contrib/runits/nodedaemon-log-config.runit /data/logs/nodedaemon/config chmod +x /etc/service/${DAEMON}/run exec /srv/explorer/source/contrib/runit_boot.sh