Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want systemd service to handle forking (my file doesn't handle forking by itself. So I'm relying on systemd for handling that)

My .service file:

[Unit]
Description=swamp services management service
After=syslog.target

[Service]
Type=forking
ExecStart=/usr/bin/swamp

[Install]
WantedBy=multi-user.target

Question

Is specifying Type=forking enough for what I'm trying to achieve? Or is it similar to expect forking in upstart which actually tells upstart (if I understand correctly, not sure I do, I'm new at writing initscripts) that my service would handle forking/daemonizing.

share|improve this question

1 Answer 1

systemd has excellent documentation. See the page on service files:

If set to forking, it is expected that the process configured with ExecStart= will call fork() as part of its start-up. The parent process is expected to exit when start-up is complete and all communication channels are set up. The child continues to run as the main daemon process. This is the behavior of traditional UNIX daemons. If this setting is used, it is recommended to also use the PIDFile= option, so that systemd can identify the main process of the daemon. systemd will proceed with starting follow-up units as soon as the parent process exits.

So, using that type will just tell systemd to wait until swamp returns and then consider it to be still running: making that happen remains your responsibility...

share|improve this answer
    
If the script doesn't do any forking, it's either oneshot (a typical short running script) or simple (a long-running service that that doesn't fork+exit). –  Pavel Šimerda Apr 26 at 17:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.