Page MenuHomePhabricator

Make many minor improvements to daemon behavior
ClosedPublic

Authored by epriestley on May 26 2016, 3:19 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 18, 6:00 AM
Unknown Object (File)
Mon, Oct 28, 10:51 PM
Unknown Object (File)
Oct 16 2024, 8:46 PM
Unknown Object (File)
Oct 16 2024, 5:56 AM
Unknown Object (File)
Oct 15 2024, 11:34 AM
Unknown Object (File)
Oct 1 2024, 1:05 PM
Unknown Object (File)
Oct 1 2024, 1:04 PM
Unknown Object (File)
Oct 1 2024, 1:04 PM
Subscribers
None

Details

Summary

Ref T10811.

First, declare() at constructor scope doesn't actually work properly, because PHP is a beautiful language full of wonderful and interesting ideas. Instead, it affects file scope (or something???). In practice, this is often the same thing, except that sometimes it isn't.

To reproduce this, run:

libphutil/ $ echo '{}' | php ./scripts/daemon/exec/exec_daemon.php PhutilHangForeverDaemon --verbose

Then send it SIGTERM. Before the change, it ignores the signal. Now, it exits properly.

Second, stuff was printing <<VERB>> and such by accident because of typos. Fix the extra <> so this just prints <VERB>. I observed proper terminal output after this patch.

Third, always print when we catch a signal. Hopefully this will help identify possible problems related to rogue signals. I observed messages about caught signals.

Fourth, when a script emits some text on stderr, print each line separately. This aligns things better and makes them easier to read. I observed multi-line messages spread across multiple lines with headers on each line, aligning more readably.

Fifth, add a missing period

Sixth, after a subprocess gets kill -9'd, exit with error code 128 + 9 (137) instead of -1 (and likewise for other signal codes, if any exist). I kill -9'd a daemon and saw a more useful exit code.

Test Plan

See above for particulars.

Also ran bin/phd debug ... and signaled processes, observed normal operation and more useful log output.

Diff Detail

Repository
rPHU libphutil
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

epriestley retitled this revision from to Make many minor improvements to daemon behavior.
epriestley updated this object.
epriestley edited the test plan for this revision. (Show Details)
epriestley added a reviewer: chad.
chad edited edge metadata.
This revision is now accepted and ready to land.May 26 2016, 4:11 AM
This revision was automatically updated to reflect the committed changes.