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

Worker and pcntl_exec support #11

Closed
quazardous opened this issue Apr 27, 2018 · 9 comments
Closed

Worker and pcntl_exec support #11

quazardous opened this issue Apr 27, 2018 · 9 comments

Comments

@quazardous
Copy link

I use pcntl_exec to isolate curl calls because curl is not multi process safe.

I was wondering how I could use php-daemon and workers and be able to handle the return code of the code ran under pcntl_exec()

@lifo101
Copy link
Owner

lifo101 commented Apr 27, 2018

I'm not familiar with how pcntl_exec works. Have you tried to use it within your daemon yet? If you call that method while in a worker process, it might not cause any issues. But, since pcntl_exec "replaces" the current process with the sub process, I'm not sure what side effects that will have on the worker process, it may break it's communication with the parent daemon process.

@lifo101
Copy link
Owner

lifo101 commented Apr 27, 2018

I will also add, that if you're just triggering a worker to 'fire and forget' the process, then you should be able to maybe safely use a Task, since those don't communicate to the daemon parent.

@quazardous
Copy link
Author

and is it possible to retrieve Task exit code ?

@quazardous
Copy link
Author

Have you tried to use it within your daemon yet

I've a somewhat handmade daemon using fork and pcntl_exec() but not with your Daemon yet

@lifo101
Copy link
Owner

lifo101 commented Apr 27, 2018

If you use a Worker, then you can return the exit code, but not from a Task.

@quazardous
Copy link
Author

crap I'm stuck ...
could exit code for Task be something you'll consider usefull ?

@lifo101
Copy link
Owner

lifo101 commented Apr 27, 2018

That is why there are Workers.

@quazardous
Copy link
Author

quazardous commented Apr 27, 2018

I mean the low level pcntl_wexitstatus

could be an event

@lifo101
Copy link
Owner

lifo101 commented Apr 27, 2018

The Daemon::task method returns a Process object that represents the sub process that was started. Using that object you can interact with the process. ie: get it's PID, etc. Using that you might be able to do more of what you want to do.

@lifo101 lifo101 closed this as completed May 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants