From cf6654c17807562e5464e6bfbd8b9663722112e2 Mon Sep 17 00:00:00 2001 From: redfish Date: Wed, 24 Aug 2016 23:05:30 -0400 Subject: [PATCH] contrib: example systemd service and config file Including in light of #977 --- README.md | 15 +++++++++++---- utils/conf/bitmonerod.conf | 7 +++++++ utils/systemd/bitmonerod.service | 22 ++++++++++++++++++++++ 3 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 utils/conf/bitmonerod.conf create mode 100644 utils/systemd/bitmonerod.service diff --git a/README.md b/README.md index 24b2840c..49c90080 100644 --- a/README.md +++ b/README.md @@ -215,16 +215,23 @@ foreground: ./bin/bitmonerod -To run in background: - - ./bin/bitmonerod --log-file bitmonerod.log --detach - To list all available options, run `./bin/bitmonerod --help`. Options can be specified either on the command line or in a configuration file passed by the `--config-file` argument. To specify an option in the configuration file, add a line with the syntax `argumentname=value`, where `argumentname` is the name of the argument without the leading dashes, for example `log-level=1`. +To run in background: + + ./bin/bitmonerod --log-file bitmonerod.log --detach + +To run as a systemd service, copy +[bitmonerod.service](utils/systemd/bitmonerod.service) to `/etc/systemd/system/` and +[bitmonerod.conf](utils/conf/bitmonerod.conf) to `/etc/`. The [example +service](utils/systemd/bitmonerod.service) assumes that the user `bitmonero` exists +and its home is the data directory specified in the [example +config](utils/conf/bitmonerod.conf). + ## Internationalization See README.i18n diff --git a/utils/conf/bitmonerod.conf b/utils/conf/bitmonerod.conf new file mode 100644 index 00000000..64a02741 --- /dev/null +++ b/utils/conf/bitmonerod.conf @@ -0,0 +1,7 @@ +# Configuration for bitmonerod +# Syntax: any command line option may be specified as 'clioptionname=value'. +# See 'bitmonerod --help' for all available options. + +data-dir=/var/lib/bitmonero +log-file=/var/log/bitmonero/bitmonero.log +log-level=0 diff --git a/utils/systemd/bitmonerod.service b/utils/systemd/bitmonerod.service new file mode 100644 index 00000000..da012c4e --- /dev/null +++ b/utils/systemd/bitmonerod.service @@ -0,0 +1,22 @@ +[Unit] +Description=Monero cryptocurrency node +After=network.target + +[Service] +User=bitmonero +Group=bitmonero +WorkingDirectory=~ + +Type=forking +ExecStart=/usr/bin/bitmonerod --config-file /etc/bitmonerod.conf --detach + +# This is necessary because bitmonerod does not yet support +# writing a PID file, which means systemd tries to guess the PID +# by default, but it guesses wrong (sometimes, depending on +# random timing of events), because the daemon forks twice. +# The ultimate fix is for the daemon to write a PID file, and +# a workaround is to disable the guessing feature in systemd. +GuessMainPID=no + +[Install] +WantedBy=multi-user.target