rfc:cli_process_title

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
rfc:cli_process_title [2013/02/07 05:42] keyurrfc:cli_process_title [2013/02/19 06:09] – Removing reference to 5.4 keyur
Line 1: Line 1:
 ====== Request for Comments: PHP CLI changing process title support ====== ====== Request for Comments: PHP CLI changing process title support ======
  
-  * Version: 1.0+  * Version: 1.1
   * Date: 2013-02-06   * Date: 2013-02-06
   * Author: Keyur Govande <kgovande@gmail.com>   * Author: Keyur Govande <kgovande@gmail.com>
Line 11: Line 11:
 This RFC proposes a new way of setting a PHP CLI process's title that's visible in top or ps. The implementation is based based off the one in [[http://www.postgresql.org/docs/9.2/static/monitoring-ps.html|PostgreSQL]].  This RFC proposes a new way of setting a PHP CLI process's title that's visible in top or ps. The implementation is based based off the one in [[http://www.postgresql.org/docs/9.2/static/monitoring-ps.html|PostgreSQL]]. 
  
 +This is very helpful when using PHP as a daemon, for example: [[https://github.com/brianlmoon/GearmanManager|GearmanManager]]. Otherwise, all job workers look the same in top and ps:
 +
 +''php -d display_errors=1 -d display_startup_errors=1 -d error_log=/var/log/gearman/php.log /var/code/bin/GearmanManager/run-gearman.php -c /var/code/bin/GearmanManager/config.php -p JobWorker_ -P /var/run/gearman_manager/gearman_manager.pid -d -x 86400 -w /var/code/phplib/JobWorker/ -l /var/log/gearman/gearman_manager.log -vvv''
 +
 +Currently, there are 2 ways to debug what job a process is doing: attach gdb and introspect the appropriate data structure. Or log the process-pid to a file at job start-up and match it up. 
 +
 +Both are doable, but time consuming and having functionality in the language to set the title would solve the problem nicely.
 ===== Implementation ===== ===== Implementation =====
  
Line 32: Line 39:
  
 $title = "This is a test title"; $title = "This is a test title";
-if (!is_cli_ps_title_available()) { +if (!cli_set_process_title($title)) { 
-    echo "Not supported on this OS\n";+    echo "Unable to set title\n";
     exit(1);     exit(1);
-} 
- 
-if (!set_cli_ps_title($title)) { 
-    echo "Unable to set title\n"; 
-    exit(2); 
 } }
  
Line 50: Line 52:
   * FreeBSD 9.0: {{:rfc:fbsd_ps_title.png?200|}}   * FreeBSD 9.0: {{:rfc:fbsd_ps_title.png?200|}}
   * Windows 7: {{:rfc:windows_ps_title.png?200|}}   * Windows 7: {{:rfc:windows_ps_title.png?200|}}
 +  * OS X Lion: {{:rfc:osx_ps_title.png?200|}}
  
 ===== Patch ===== ===== Patch =====
  
-The patch (including tests) is [[https://gist.github.com/keyurdg/4728770#file-php_ps-patch|here]]. +The pull request (including tests) based on PHP-5.5 is [[https://github.com/php/php-src/pull/280|here]].
 ===== Voting ===== ===== Voting =====
  
 The PHP language is not changed, so a 50% + 1 majority is required. The PHP language is not changed, so a 50% + 1 majority is required.
 +
 +Voting ends March 4th, 2013.
 +
 +<doodle title="Accept modifying CLI process title in PHP?" auth="user" voteType="single" closed="false">
 +   * Yes
 +   * No
 +</doodle>
  
 ===== Changelog ===== ===== Changelog =====
  
   * 1.0 (2012-02-06): Initial draft   * 1.0 (2012-02-06): Initial draft
 +  * 1.1 (2012-02-07): Updated the introduction with more justification for why this is needed
rfc/cli_process_title.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1