A service should only start when a request arrives on its port, to save memory. How?
AdvancedScenarioProcesses, services and systemd
Answer
Situation read → Socket activation.
What I'd do →
/etc/systemd/system/tool.socket:
[Socket]
ListenStream=9000
[Install]
WantedBy=sockets.target
tool.servicewithExecStart=/usr/local/bin/tooland the app reading the inherited socket (LISTEN_FDS).systemctl enable --now tool.socket.
Why → systemd holds the port; the first connection starts the service, and no connection is lost during startup.
Interview tip → The app must support receiving the socket from systemd; not every app does.
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