-
Notifications
You must be signed in to change notification settings - Fork 241
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
New function (imported from ezscriptmonitor) to launch a script in background #236
base: master
Are you sure you want to change the base?
Conversation
} | ||
else | ||
{ | ||
exec( $command . ' > /dev/null &' ); |
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.
Why not taking advantage of PCNTL if present instead ? The exec() call would be used as a (dirty) fallback then
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.
Because I'm currently fighting with it :) I can't succeed in creating a subprocess in background in a php page launched in apache environment
But you're right, it would be nice to have pcntl if available, and if possible to do this
But for now, why not merging this new function right now, and improve it afterwards with pcntl?
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.
Oh right, now I understand the e-mail you sent to @bdunogier ;-)
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.
Yes :)
Indeed for my need to launch a process in background from ezjscore/call, I've discovered I can use ezscriptmonitor that fits my need
However the question on pcntl in apache env is still interesting, in order to improve this function and avoid the (dirty) exec.
But as said before, maybe it's worth merging now, and improve it afterwards :)
Tell me if it can't be merged for some reason
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.
So for the question on "how to use pcntl in apache environment ?", the answer is there:
http://fr2.php.net/manual/en/intro.pcntl.php
Php advises to never do that...
As a result, an enhancement to this function could be to use pcntl yes, but in cli env, not in apache env
Well, they can use it now, though it would be easier to discover if it was part of the new API. I agree it is essential enough to move it to the kernel, but opinions differ. |
Any votes on this? |
@bdunogier you're coding some daemon logic to ezpublish I can remember :) so what do you think about this pull to add a function to launch a process in background in the core API ? |
This function that can launch a script in background is very handy, from extension/ezscriptmonitor/cronjobs/runscheduledscripts.php
=> Why not moving it to eZPublish API?
That way, a lot of people could use it
Further more, in eZRunCronjobs, it would be possible to add a new method that launches runcrunjobs at once (in order to not wait the next launch of cronjob)
It would also be possible to have a button somewhere in the backend to force the launch of the runcronjobs for example...
And in fact, as far as I'm concerned, I need to add a script to ezscriptmonitor, and launch this script asap, I just can't wait 5 min (if the cron is running every 5 min), I need to launch runcronjobs asap (hence this function that would let it possible)
This method has been put in eZScript, I really don't know if this is the best place...
Do not hesitate to comment this pull !