[Ethereum] How to setup parity daemon

parity

I know parity can run as a daemon because the –help has a usage parity daemon <pid-file> [options] but no further help/clues/documentation is provided. What is <pid-file> ? A process ID file, and what is that? If it is supposed to be a systemd unit file why doesn't it say so.

The only other clue I can find after searching and searching is this:
https://daowiki.atlassian.net/wiki/display/DAO/Ethereum+network
It says to edit the parity.service and parity.conf file, however both of those do not exist. I can try creating them but then why is there NOTHING when googling on this. I can't be the first and only person on this planet to want to run parity as a daemon. (I don't want this question to sound negative. I really appreciate the great contribution the ethcore team and their parity project has given to the Ethereum community!)

Ubuntu 16.04
parity v1.2.2

Best Answer

TL;DR - it's just a path to an empty file of your choice, and prevents multiple instances of the daemon from running. (I don't think the file even needs to exist - it will be created for you.)


Parity uses the general Rust implementation of daemonize(), which itself takes a pid_file argument.

Taking things one step further, the Rust implementation is based on Python's daemonize library, which again uses the same idea.

The basic idea is to prevent multiple versions of your script/program running at the same time. Your pid_file argument is just a path to a file where the pid will be stored, which at first will be empty, but which will be written to by the running program.

  • When the script starts, the first thing it does it look for a file (wherever you've put it - probably something like /tmp/parity_daemon.pid);
  • If that file exists, then the script reads a pid from it. The script now checks if any process with that pid is already running. (Note that the pid file should be cleaned up when the daemon gracefully exits, but it's possible the daemon crashed on its last run, so the pid file still exists.);
  • If there is a process running with that pid, then there is already a running instance of this program/daemon, so the new daemon instance should exit.
Related Topic