Template the baseline pidfile so deployments can relocate or disable it
without patching conf/rspamd.conf:
pidfile = "{= env.PIDFILE|default('$RUNDIR/rspamd.pid') =}";
With no RSPAMD_PIDFILE set it renders to the previous default
($RUNDIR/rspamd.pid). An empty RSPAMD_PIDFILE renders an empty string,
which now means "do not write a pidfile" -- useful when running as PID 1
in a container. Extend the existing cfg->pid_file == NULL guards in both
rspamd_write_pid() and main() to also treat an empty string as unset, so
the existing "pid file is not specified" path is taken.
.include "$CONFDIR/common.conf"
options {
- pidfile = "$RUNDIR/rspamd.pid";
+ # An empty RSPAMD_PIDFILE disables writing a pidfile (useful when running
+ # as PID 1); otherwise it overrides the default location.
+ pidfile = "{= env.PIDFILE|default('$RUNDIR/rspamd.pid') =}";
.include "$CONFDIR/options.inc"
.include(try=true; priority=1,duplicate=merge) "$LOCAL_CONFDIR/local.d/options.inc"
.include(try=true; priority=10) "$LOCAL_CONFDIR/override.d/options.inc"
{
pid_t pid;
- if (main->cfg->pid_file == NULL) {
+ if (main->cfg->pid_file == NULL || main->cfg->pid_file[0] == '\0') {
return -1;
}
main->pfh = rspamd_pidfile_open(main->cfg->pid_file, 0644, &pid);
sigpipe_act.sa_flags = 0;
sigaction(SIGPIPE, &sigpipe_act, NULL);
- if (rspamd_main->cfg->pid_file == NULL) {
+ if (rspamd_main->cfg->pid_file == NULL ||
+ rspamd_main->cfg->pid_file[0] == '\0') {
msg_info_main("pid file is not specified, skipping writing it");
skip_pid = TRUE;
}