I'm looking for process manager which can be controlled from CLI (add, start, stop, delete), so I can control it programmatically.

I've tried using https://github.com/circus-tent/circus, but the problem is when I add it from CLI, the processes is disappear after server restart. I opened an issue there; https://github.com/circus-tent/circus/issues/937. I didn't try Supervisord yet, but it seems has the same issue, https://github.com/mnaberez/supervisor_twiddler/issues/4.

Is there any process manager which can add daemon process from CLI, and the changes is persist after restart, without touching the configuration file? Thanks.

I'm on Centos 7, I want to daemonize a PHP CLI script for each registered user.

Sorry I'm not sure how can I explain this better. I have a PHP CLI script which has infinite loop. The script is running to listen to new incoming message. The script should be started on new registered user e.g php listen.php --user_id=111, and stopped on deleting user.

  • You should give more informations about the OS and the process you want to manage. – Vinz Nov 3 '15 at 10:29
  • What do you mean by process? In Linux a process never exists after shutdown or reboot. What changes do you want to persist after restart? Linux has systemd that enables you to set up processes to be started and stopped, and will automatically start processes at boot and terminate them at shutdown. – RobertL Nov 3 '15 at 10:52
  • @Vinz I'm on Centos 7, I'm trying to daemonize a PHP script on each new registered user. – sulaiman sudirman Nov 3 '15 at 13:28
  • @RobertL I've updated my post. Let me know if you have anymore confusion. Thanks. – sulaiman sudirman Nov 3 '15 at 13:29
  • Please describe what you mean by "daemonize a PHP script on each new registered user." I think I know what will work, but I don't want to write an answer until I'm more sure it will answer your question. Please edit your question for this. – RobertL Nov 4 '15 at 5:15

The package I recommend for this is called daemontools by Dan Bernstein.

This is a collection of tools to provide system-wide service supervision and to manage services. It not only cares about starting and stopping services, but also supervises the service daemons while they are running. Amongst other things, it provides a reliable interface to send signals to service daemons without the need for pid-files, and a log facility with automatic log file rotation and disk space limits.

It satisfies all of your requirements. It's ultra-reliable, once you set it up and understand how to use it, it requires very little maintenance. If there's a problem in your system, it won't be daemontools.

  1. All control is via command line.
  2. The daemons will be restarted on sytem restart.
  3. The daemons can be stopped, started, stopped, suspended from the CLI.
  4. Plus, handles logging for each daemon too.
  5. It's manages fast restarts (when a program dies quickly).

This package and underlying design are rock solid. The source code hasn't changed in years, but don't let that fool you. It hasn't needed to change because it's correct.

I've personally used this package to reliably control hundreds of daemon processes on one machine at a time.

Configuration of a new client is easy, just place a control file in the specified directory and it will be automatically started and restarted forever, unless you intervene. Once you know what the file should look like then you make a template or a way to parameterize the control file creation.

I think your best bet is to get the RPM source package from kteru on github and build your own RPM from it. It's easy to build, but the RPM will make it easier to manage and replicate your system.

The homepage and documentation are located at http://cr.yp.to/daemontools.html

The CentOS 4-7 RPM source package is available on github: https://github.com/kteru/daemontools-rpm

There's also a package called runit that I think is a branch of daemontools without some of the licensing and distribution restrictions of daemontools and a more flexible directory layout policy. It is in the Debian repositories, I don't know about CentOS.

  • @sulaiman Is this the kind of process manager you have in mind? – RobertL Nov 5 '15 at 7:35

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.