Skip to content

Commit

Permalink
Logging files with rotation and print to stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
RCasatta authored and greenaddress committed Jun 6, 2019
1 parent 017e926 commit bdb8736
Show file tree
Hide file tree
Showing 16 changed files with 52 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ terraform/.terraform
terraform/.terraform/environment
terraform/*.tfstate.backup
terraform/*.tfstate
*~
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions contrib/runits/bitcoin_for_liquid-log-config.runit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
u127.0.0.1:23394
p1-
2 changes: 2 additions & 0 deletions contrib/runits/bitcoin_for_liquid-log.runit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec svlogd /data/logs/bitcoin
2 changes: 2 additions & 0 deletions contrib/runits/electrs-log-config.runit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
u127.0.0.1:23394
p2-
2 changes: 2 additions & 0 deletions contrib/runits/electrs-log.runit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec svlogd /data/logs/electrs
2 changes: 2 additions & 0 deletions contrib/runits/nginx-log-config.runit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
u127.0.0.1:23394
p3-
2 changes: 2 additions & 0 deletions contrib/runits/nginx-log.runit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec svlogd /data/logs/nginx
2 changes: 2 additions & 0 deletions contrib/runits/nodedaemon-log-config.runit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
u127.0.0.1:23394
p4-
2 changes: 2 additions & 0 deletions contrib/runits/nodedaemon-log.runit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec svlogd /data/logs/nodedaemon
2 changes: 2 additions & 0 deletions contrib/runits/prerenderer-log-config.runit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
u127.0.0.1:23394
p5-
2 changes: 2 additions & 0 deletions contrib/runits/prerenderer-log.runit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec svlogd /data/logs/prerenderer
3 changes: 3 additions & 0 deletions contrib/runits/socat.runit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh -e

exec socat UDP-RECV:23394 stderr
2 changes: 2 additions & 0 deletions contrib/runits/tor-log-config.runit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
u127.0.0.1:23394
p6-
2 changes: 2 additions & 0 deletions contrib/runits/tor-log.runit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec svlogd /data/logs/tor
27 changes: 23 additions & 4 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"'
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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

0 comments on commit bdb8736

Please sign in to comment.