0

There is a daemon that can be started from command line and from systemctl.

/etc/systemd/system/mydaemon.service contains ExecStart= and PIDFile= so Systemd can surely detect that service is running or not:

[Unit]
After=network-online.target

[Service]
Type=simple
ExecStart=/usr/local/bin/mydaemon --no-fork
PIDFile=/var/run/mydaemon-%i.pid

[Install]
WantedBy=multi-user.target

Why "systemctl status mydaemon" says that daemon is stopped even if it's running?

How to teach systemd that daemon can be running not only via "systemctl start" but also directly?

  • Are you sure your daemon writes the corresponding PID file when it starts? – Tero Kilkanen Jul 6 '17 at 15:55
  • Yes, I'm sure. PID file is actual. – user2743554 Jul 7 '17 at 12:22
  • Could you share your .service file? – Alexander Tolkachev Jul 9 '17 at 20:22
  • Well, mydaemon.service file added. – user2743554 Jul 11 '17 at 1:20
4

Don't do it. Always start it with systemctl. Shutdown the service and bring it up in such a way the systemd knows about it.

This probably isn't the answer you want. It may even be possible to do what you're asking, but why bother?

0

Well, I checked systemd manual and haven't found any information how to inform systemd about manually started process. I don't look deep, but i think there is could be possibility, to do it trough sending messages to systemd about process start, but it's to complicated for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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