An app forks into a background daemon itself. systemd thinks it died right after start. How do you configure the unit?
IntermediateScenarioProcesses, services and systemd
Answer
Situation read → Wrong service Type.
What I'd do →
- Best: run the app in the foreground (most have a
--foregroundor-Dflag) and keepType=simpleorexec. - If it must fork:
[Service]
Type=forking
PIDFile=/run/myapp/myapp.pid
ExecStart=/usr/sbin/myapp -d
Why → With Type=simple, the parent exits after forking and systemd considers the service stopped and may kill the child.
Interview tip → Mention Type=notify for apps that signal readiness with sd_notify.
More on Processes, services and systemd
Your team has a Python API that someone starts with `nohup python app.py &`. Make it a proper service running as a non-root user.BeginnerThe service you created must bind to port 443, but it runs as a non-root user. How?BeginnerYou need to change one setting (memory limit) in a vendor-supplied unit file without editing it. How?BeginnerA service depends on a database on the same host and fails at boot because the DB isn't ready. How do you fix the ordering?IntermediateA service keeps crashing and systemd stops restarting it after a few attempts. How do you tune this?IntermediateA long-running app must reload its config without dropping connections. How do you wire this into systemd?Intermediate