#683 Fails to daemonize under systemd

Reporter Peter Colberg
Owner Zash
Created
Updated
Stars ★★ (3)
Tags
  • Priority-Medium
  • Status-WontFix
  • Type-Defect
  1. Peter Colberg on

    I am trying to start prosody using the following systemd service. Note how I am using Type=forking together with PIDFile so that systemd waits for prosody to start listening on its port. systemd considers the service started the moment prosody creates the PID file. This allows further dependent services to wait on prosody if needed. # /etc/systemd/system/prosody.service [Unit] Description=Prosody XMPP (Jabber) Server After=network.target [Service] Type=forking PIDFile=/var/run/prosody/prosody.pid User=prosody ExecStart=/usr/bin/prosody ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure [Install] WantedBy=multi-user.target The prosody config file contains these options relevant for daemonization: daemonize = true; pidfile = "/var/run/prosody/prosody.pid"; Trying to start prosody.service fails with this error: prosody: mod_posix: Failed to daemonize: already-daemonized I am using prosody 0.9.10 on Debian stretch (Linux x86_64). The error results from the following code in the file util-src/pposix.c: if ( getppid() == 1 ) { lua_pushboolean(L, 0); lua_pushstring(L, "already-daemonized"); return 2; } The above test is not sufficient to determine whether the process is daemonized or not, since any process started from systemd will have a parent pid equal to 1. Could you please remove this code to permit prosody to daemonize under systemd?

  2. Zash on

    Why daemonize if already daemonized? You can set daemonize = false and change Type to simple in the service file.

    Changes
    • owner Zash
    • tags Status-WontFix

New comment

Not published. Used for spam prevention and optional update notifications.