Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

Daemonize #8

Closed
whatisgravity opened this issue Jul 28, 2016 · 14 comments
Closed

Daemonize #8

whatisgravity opened this issue Jul 28, 2016 · 14 comments

Comments

@whatisgravity
Copy link

Users on reddit were asking about this, does not yet seem to be added yet.

ethereum/go-ethereum#2608

It should be easy to add if it does not get added to upstream soon.

@LeChuckDE
Copy link

Wrote a upstart script for it ... easy like hell ....

@whatisgravity
Copy link
Author

whatisgravity commented Jul 31, 2016

Yeah, that is how I would handle it too, but the ability to daemonize from cli would be a trivial addition. Would you mind sharing your script for the benefit of others if you have not already?

Other solutions include using screen or

nohup ./geth &

However I prefer alternative methods.

@LeChuckDE
Copy link

LeChuckDE commented Jul 31, 2016


description "Start geth-node for Ethereum Classic"

env DAEMON=/Path/to/geth-binary/geth
env CONFIG=" --oppose-dao-fork --fast --cache 512 --rpc --rpcaddr 127.0.0.1 --rpcport 8275 --rpcapi web3,admin,eth,net console"

start on filesystem or runlevel [2345]
stop on runlevel [!2345]

setuid <geth username>
setgid <geth username>

kill signal INT

respawn
respawn limit 10 5
umask 022

pre-start script
    test -x $DAEMON || { stop; exit 0; }
end script

# Start
script
    exec $DAEMON $CONFIG
end script

`

here that is mine.

Save it as geth-etclassic.conf under your homedirectory

sudo cp ~/geth-etclassic.conf /etc/init/
then you could start it with:
start geth-etclassic (restart and stop also possible)
to get output:
tailf /var/log/geth-etclassic.log

to work with it start a geth attach with same user like geth is running

@LeChuckDE
Copy link

with screen :
sudo apt-get -Y install screen

screen -S geth-etclassic
geth c --oppose-dao-fork --fast --cache 512 --rpc --rpcaddr 127.0.0.1 --rpcport 8275 --rpcapi web3,admin,eth,net console

Press Ctrl(keep pressed) + A + D +Release Crtl to leave screen session.
to reattach:

screen -r geth-etclassic

@whatisgravity
Copy link
Author

Thanks, I'm sure those will help others and if I see that question get asked again I can simply link them here. We can also eventually incorporate it into a wiki page or some guide.

@fernetmatt
Copy link

i'd prefer to have this feature embedded into the cli
geth --daemon --logfile "/var/log/geth.log"

@whatisgravity
Copy link
Author

I'm still interested in adding the daemon flag or separate daemon binary. If anyone is interested in creating a pull request for this issue, reach out. If no one volunteers I will add these changes before the next release.

@mikeyb
Copy link
Contributor

mikeyb commented Sep 4, 2016

A slightly easier one liner screen command to drop geth into the background

Screen Examples

General startup of client

screen -S geth -d -m bash -lc 'geth --oppose-dao-fork --fast console'

Start client and unlock first wallet

screen -S geth -d -m bash -lc 'geth --oppose-dao-fork --fast --unlock 0 console'

Attach to screen running geth

screen -x geth

Detach from the screen when done

ctrl+a then d

@pascaldekloe
Copy link
Contributor

Go has issues with deamonizing: golang/go#227
We could ship with some example configurations like Unix init scripts, supervisord, etc...

sorpaas pushed a commit that referenced this issue Nov 21, 2017
NewEnv now returns only environment, error is removed. Files formatted by gofmt
@camstuart
Copy link

I would have thought that a systemd unit file such as this one: https://gist.github.com/swaldman/e58a866eafc4ff043c4099e394901a1e would be the way to go.

Systemd will capture stdout/err and direct it to anywhere you want. By default, it goes to syslog.

So perhaps maybe some gists of systemd for linux OS's and launchd for OSX with instructions would satisfy this requirement? I would be happy to do this.

@whilei
Copy link
Contributor

whilei commented Sep 20, 2018

That sounds great @camstuart. I've used systemctl on linux for this before and it works fine (using then journalctl to monitor logs, and logrotate for, well, log rotation). Haven't used launchd personally, but I expect similar.

A gist or gists would be very welcome 👍

@camstuart
Copy link

camstuart commented Sep 20, 2018

Ok @whilei I'll see what I can do. where would the gists live? this repo? I have never contributed a gist before. is it similar to a PR. If you have a guide, then I'll get up to speed on it.

@whilei
Copy link
Contributor

whilei commented Oct 4, 2018

I think the gist should be separate from this repo. One solution would be if you create a gist.github.com, then a link to that gist could be included in the wiki at an appropriate spot.

Open to other solutions as well.

@camstuart
Copy link

Yeah sounds good @whilei, will do

@soc1c soc1c closed this as completed Jun 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants