Page MenuHomePhabricator

Have `bin/phd stop` look for daemons and warn you about them, or nuke them with some flag
Closed, ResolvedPublic

Description

Sometimes, for whatever reason, daemon processes survive phd stop. After killing daemons we know about, we should run ps auxwww or similar and look for still-living daemons, and warn the user:

WARNING: Some daemons seem to have survived:

  2932  php ./launch_daemon.php PhabricatorGarbageCollectorDaemon --daemonize
        --load-phutil-library=/core/arcanist/src
        --load-phutil-library=/core/phabricator/src
        --conduit-uri=https://secure.phabricator.com/api/
        --log=/var/tmp/phd/log/daemons.log --phd=/var/tmp/phd/pid

Use `phd stop --force` to forcibly kill these processes.

Then, with --force, we should kill them.

Event Timeline

epriestley triaged this task as Normal priority.
epriestley added a project: Daemons.
epriestley added a subscriber: epriestley.

To reproduce this easily, do:

phabricator/ $ bin/phd launch nice # launches a "nice" daemon that does nothing

Normally, phd stop should be able to stop this daemon.

To reproduce the problem, launch a daemon and then remove the PID file:

rm -rf /var/tmp/phd/pid/* # or wherever these live on your system

Now, phd stop should fail to find the daemon.

You can launch several "nice" daemons with:

phabricator/ $ ./bin/phd launch 4 nice

What is the correct way to distinguish between Phabricator daemons and other processes in the output from ps auxwww? It seems like you would need a filter that wouldn't delete other processes by mistake.

I think looking for the strings exec_daemon.php or launch_daemon.php is good for now. If you want to be extra paranoid, you could additionally require that --daemonize (keeps it from killing phd debug) and --load-phutil-library= (keeps it from killing scripts which happen to be named exec_daemon.php) be present.

The kill code I mentioned is in PhutilDaemonOverseer->annihilateProcessGroup() (in libphutil/).

  • D5663 added a reasonable-looking way to detect these processes, but bin/phd never got the glue code to call it.
  • This task is otherwise still relevant:
    • Add code in bin/phd stop and bin/phd restart to warn the user that there are processes which look like daemons that don't have corresponding PID files, and that they can use --force to terminate them.
    • With --force, terminate these processes.
    • The steps in https://secure.phabricator.com/T2374#8 should still let you reproduce this in modern phd.
avivey changed the visibility from "All Users" to "Public (No Login Required)".Nov 16 2016, 6:44 PM