Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jdespatis
Copy link
Contributor

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 !

}
else
{
exec( $command . ' > /dev/null &' );
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

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 ;-)

Copy link
Contributor Author

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

Copy link
Contributor Author

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

@glye
Copy link
Member

glye commented Dec 1, 2011

=> Why not moving it to eZPublish API?
That way, a lot of people could use it

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.

@andrerom
Copy link
Contributor

Any votes on this?

@jdespatis
Copy link
Contributor Author

@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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants