PHP-Daemon icon indicating copy to clipboard operation
PHP-Daemon copied to clipboard

Command line arguments not retained after automatic restart

Open theintz opened this issue 10 years ago • 5 comments

I am using command line arguments to control the behavior of the daemon, but they are lost when the daemon restarts. This makes the auto-restart feature unusable for me.

The problem centers around Core_Daemon::command() where the filename of the script is built. Here some default arguments (-d --recoverworkers) are appended, but the original arguments are not mentioned at all.

theintz avatar Aug 18 '14 17:08 theintz

Sorry you're having trouble! Can you overload the command() method to include your own params?

shaneharter avatar Aug 18 '14 19:08 shaneharter

Unfortunately not, because it's marked private.

theintz avatar Aug 21 '14 16:08 theintz

If you'd like to change to protected and send a pull request I'm happy to merge it. Being private was strictly about choosing the most conservative option.

On Thu, Aug 21, 2014 at 9:13 AM, Tobias Heintz [email protected] wrote:

Unfortunately not, because it's marked private.

— Reply to this email directly or view it on GitHub https://github.com/shaneharter/PHP-Daemon/issues/53#issuecomment-52943287 .

shaneharter avatar Aug 21 '14 16:08 shaneharter

Great, I'll try it out locally and if that solves the issue (combined with saving the arguments in getopt() it should), I'll send you a pull request.

theintz avatar Aug 21 '14 16:08 theintz

I've made command() (or rather the 2.0 equivalent getFilename) protected and I'm overriding it in my daemon class. In getopt() I'm saving the entirety of $argv. This solution seems to work nicely. Since I'm working on 2.0, I can't send a pull request to your current master. Maybe you can fix it directly?

theintz avatar Aug 26 '14 15:08 theintz