Page MenuHomePhabricator

Make many minor improvements to daemon behavior
ClosedPublic

Authored by epriestley on May 26 2016, 3:19 AM.
Tags
None
Referenced Files
F13059734: D15977.diff
Fri, Apr 19, 4:44 PM
Unknown Object (File)
Wed, Apr 17, 3:08 PM
Unknown Object (File)
Fri, Apr 12, 5:04 AM
Unknown Object (File)
Thu, Apr 11, 7:17 AM
Unknown Object (File)
Mon, Apr 8, 10:14 AM
Unknown Object (File)
Sat, Mar 30, 7:34 PM
Unknown Object (File)
Fri, Mar 29, 12:10 AM
Unknown Object (File)
Thu, Mar 28, 10:46 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
Branch
exit2
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 12337
Build 15605: Run Core Tests
Build 15604: arc lint + arc unit

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.