breard-r/acmed

--pid-file and foreground dosn't work toghether

rollniak opened this issue · 1 comments

Hello,

I'm actually trying to write an init script for FreeBSD for acmed 0.6.0 :

#!/bin/sh

# PROVIDE: acmed
# REQUIRE: LOGIN
# KEYWORD: shutdown

# Add the following lines to /etc/rc.conf to enable `acmed':
#
# acmed_enable="YES"
#

. /etc/rc.subr

name="acmed"
rcvar=acmed_enable

command="/usr/local/bin/acmed"
pidfile="/var/run/$name.pid"

# read configuration and set defaults
load_rc_config "$name"
: ${acmed_enable="NO"}
: ${acmed_configfile:="/usr/local/etc/acmed/$name.toml"}

required_files="${acmed_configfile}"

command_args="--pid-file ${pidfile} --config ${acmed_configfile} --log-syslog --log-level info --foregroung"

run_rc_command "$1"

the --foregroung option seems to doesn't work with --pid-file option :

$ sudo service start acmed
Starting acmed.
error: The argument '--foregroung' cannot be used with '--pid-file <FILE>'

USAGE:
    acmed --config <FILE> --foregroung --log-level <LEVEL> --pid-file <FILE> --log-syslog

For more information try --help
/usr/local/etc/rc.d/acmed: WARNING: failed to start acmed

It is normal the normal behavior or a bug ?

Best regards,
Yan

Hi!

It is normal the normal behavior or a bug ?

A little bit of both. Currently, the PID file is written by the daemonize crate and, therefore, only when it's called to fork the process in the background. Therefore:

  • it's a bug since there is no good reason to prevent writing the PID file when running in the foreground
  • it's the normal behavior since I marked --pid-file incompatible with --foreground until I write the code so they could work together

Hence, I tag this issue as a feature-request. I should include it in the next release.