MDL-68714 clilib: Allow cli processes to set a process title suffix

This commit is contained in:
Brendan Heywood
2020-07-01 18:35:32 +10:00
parent c11e2517a7
commit 73a5ba92b7
+15
View File
@@ -145,6 +145,21 @@ function cli_get_params(array $longoptions, array $shortmapping=null) {
return array($options, $unrecognized);
}
/**
* This sets the cli process title suffix
*
* An example is appending current Task API info so a sysadmin can immediately
* see what task a cron process is running at any given moment.
*
* @param string $suffix process suffix
*/
function cli_set_process_title_suffix(string $suffix) {
if (defined('CLI_SCRIPT') && isset($_SERVER['argv'])) {
$command = join(' ', $_SERVER['argv']);
@cli_set_process_title("php $command ($suffix)");
}
}
/**
* Print or return section separator string
* @param bool $return false means print, true return as string