diff options
author | Riccardo Spagni <ric@spagni.net> | 2017-08-07 15:06:59 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2017-08-07 15:06:59 +0200 |
commit | 64ebeb5aa530ff5e4999a25514e57f8312b6404d (patch) | |
tree | 81d7287d476b1baa5e64db4ec0e1da7e805c0d17 /src/daemonizer/posix_daemonizer.inl | |
parent | Merge pull request #2151 (diff) | |
parent | Update monerod systemd service file (diff) | |
download | monero-64ebeb5aa530ff5e4999a25514e57f8312b6404d.tar.xz |
Merge pull request #2182
2fac03e6 Update monerod systemd service file (Erik de Castro Lopo)
51efb217 daemon: Add ability to write a PID file (Erik de Castro Lopo)
Diffstat (limited to 'src/daemonizer/posix_daemonizer.inl')
-rw-r--r-- | src/daemonizer/posix_daemonizer.inl | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/daemonizer/posix_daemonizer.inl b/src/daemonizer/posix_daemonizer.inl index f8be15dda..506c7766f 100644 --- a/src/daemonizer/posix_daemonizer.inl +++ b/src/daemonizer/posix_daemonizer.inl @@ -43,6 +43,10 @@ namespace daemonizer "detach" , "Run as daemon" }; + const command_line::arg_descriptor<std::string> arg_pidfile = { + "pidfile" + , "File path to write the daemon's PID to (optional, requires --detach)" + }; const command_line::arg_descriptor<bool> arg_non_interactive = { "non-interactive" , "Run non-interactive" @@ -55,6 +59,7 @@ namespace daemonizer ) { command_line::add_arg(normal_options, arg_detach); + command_line::add_arg(normal_options, arg_pidfile); command_line::add_arg(normal_options, arg_non_interactive); } @@ -80,7 +85,12 @@ namespace daemonizer if (command_line::has_arg(vm, arg_detach)) { tools::success_msg_writer() << "Forking to background..."; - posix::fork(); + std::string pidfile; + if (command_line::has_arg(vm, arg_pidfile)) + { + pidfile = command_line::get_arg(vm, arg_pidfile); + } + posix::fork(pidfile); auto daemon = executor.create_daemon(vm); return daemon.run(); } |