Go-ethereum: Geth doesn't send any logs and dies when started in background

Created on 24 May 2016  路  8Comments  路  Source: ethereum/go-ethereum

System information

Geth version: Version: 1.4.3-stable
OS & Version: Linux ubuntu 14.04 LTS

Expected behaviour

logs appears in redirection

Actual behaviour

no logs

Steps to reproduce the behaviour

I try to start geth as a daemon using start-stop-daemon functionality using following scripts. There are at least 2 problems.
1) There is not logs, so I don't exactly know what's going on.
2) geth seems to die after attempt to create new account (when attached via ipc).

> personal.newAccount()
Passphrase:
Repeat passphrase:
EOF
false

"ethereum" script I try to use (derivative from https://gist.github.com/alobato/1968852)

!/bin/sh
set -e


NAME=geth
PIDFILE=/var/run/$NAME.pid

DAEMON=/usr/bin/geth
DAEMON_OPTS="--rpc --ipcpath /opt/chain/geth.ipc --autodag 2>>~/geth.log"

case "$1" in
  start)
        echo -n "Starting daemon: "$NAME
        start-stop-daemon -v --start --background --make-pidfile --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS
        echo "."
        ;;
  stop)
        echo -n "Stopping daemon: "$NAME
        start-stop-daemon --stop --oknodo --pidfile $PIDFILE
        echo "."
        ;;
  restart)
        echo -n "Restarting daemon: "$NAME
        start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $PIDFILE
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS
        echo "."
        ;;

  *)
        echo "Usage: "$1" {start|stop|restart}"
        exit 1
esac

exit 0

Most helpful comment

Still... why not to implement proper daemon mode?

I don't get it at all.

All 8 comments

It looks like this is an issue with start-stop-daemon. See http://stackoverflow.com/a/13991911 for a possible solution.

Actually, I hoped that start-stop-daemon will help me with stdout/strerr mess you decided to have.

Anyway, I decided temporary use '-C' option in start-stop-daemon and the problem 2) seems to be cause by low memory. That might be a case as I'm testing my script in vagrant with 0.5 GB of memory.

help me with stdout/strerr mess you decided to have

That sounds very constructive.

I think you will be better off using upstart or systemd instead of an rc.d style init script.
Logging to stderr and not double forking into background work nicely with those init systems.
It also works very well with supervisord, launchd and any other recent decent init.

a) I can confirm that my problem with dying geth is related to memory. Virtual Box with 2GB is fine.

b)

It looks like this is an issue with start-stop-daemon. See http://stackoverflow.com/a/13991911 for a possible solution.

Thanks for sharing this link seems that with following change to my 'start definition':

[...]
DAEMON=/usr/bin/geth
DAEMON_OPTS="--rpc --ipcapi 'admin,db,eth,debug,miner,net,shh,txpool,personal,web3' --ipcpath /opt/chain/geth.ipc --verbosity 3  --autodag"
[...]
start-stop-daemon -v --start  --background --make-pidfile --pidfile $PIDFILE --startas /bin/bash -- -c "exec $DAEMON $DAEMON_OPTS 2>>/var/log/geth.log"

c) Actually using supervisord or something similar might be the better approach, if you think that works.

d)

help me with stdout/strerr mess you decided to have

That sounds very constructive.

In https://github.com/ethereum/go-ethereum/issues/2495 you made clear that you don't think proper logging is important feature. That's fine - your write the code and support the project. However, it doesn't mean every one has to agree with you. Based on my experience lack of proper logging and daemon switch are main usability issue (along with lack way to create new account with RPC - however, I imagine that one might have some security implication).

If you want to try supervisord, maybe check
out this config that we used to have in the docker hub container: https://github.com/ethereum/go-ethereum/blob/3b4ffacd0c63952ceda96b3fafb050c91e72b420/docker/supervisord.conf#L4

I would not recommend stopsignal=QUIT (you'll get lots of useless output on exit)
but the other settings should be ok. You probably also want to run it as a non-root user ;)

Why did you hid it so well? It works!

Still... why not to implement proper daemon mode?

I don't get it at all.

+1 for daemon mode not having this is modern day software seems weird.

Was this page helpful?
0 / 5 - 0 ratings