-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Added a way to set the process title #9780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
CHANGELOG | ||
========= | ||
|
||
2.5.0 | ||
----- | ||
|
||
* added a way to set the process name of a command | ||
|
||
2.4.0 | ||
----- | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ class Command | |
{ | ||
private $application; | ||
private $name; | ||
private $processName; | ||
private $aliases = array(); | ||
private $definition; | ||
private $help; | ||
|
@@ -212,6 +213,16 @@ protected function initialize(InputInterface $input, OutputInterface $output) | |
*/ | ||
public function run(InputInterface $input, OutputInterface $output) | ||
{ | ||
if (null !== $this->processName) { | ||
if (function_exists('cli_set_process_title')) { | ||
cli_set_process_title($this->processName); | ||
} elseif (function_exists('setproctitle')) { | ||
setproctitle($this->processName); | ||
} elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) { | ||
$output->writeln('<comment>Install the proctitle PECL to be able to change the process title.</comment>'); | ||
} | ||
} | ||
|
||
// force the creation of the synopsis before the merge with the app definition | ||
$this->getSynopsis(); | ||
|
||
|
@@ -411,6 +422,25 @@ public function setName($name) | |
return $this; | ||
} | ||
|
||
/** | ||
* Sets the process name of the command. | ||
* | ||
* This feature should be used only when creating a long process command, | ||
* like a daemon. | ||
* | ||
* PHP 5.5+ or the proctitle PECL library is required | ||
* | ||
* @param string $name The process name | ||
* | ||
* @return Command The current instance | ||
*/ | ||
public function setProcessName($name) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is it called process name when the underlying methods name it process title? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. This could be change before the release of Symfony 2.5. I will open a PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see #10474 |
||
{ | ||
$this->processName = $name; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Returns the command name. | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the problems with
setproctitle
pointed out in cli_set_process_title RFC (https://wiki.php.net/rfc/cli_process_title), is it really wise to use this?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We used to use both function, and we have no issue with theses.