8000 Add support of hot code reloading · Issue #14 · php-pm/php-pm · GitHub
[go: up one dir, main page]

Skip to content

Add support of hot code reloading #14

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

Closed
Koc opened this issue Apr 28, 2014 · 14 comments
Closed

Add support of hot code reloading #14

Koc opened this issue Apr 28, 2014 · 14 comments

Comments

@Koc
Copy link
Koc commented Apr 28, 2014

It would be nice add support of automatic graceful reloading user's scripts when it's updated.

As I understand - there is one way to do it: graceful restart of workers.

@trq
Copy link
Contributor
trq commented Apr 29, 2014

Yeah, this entire concept is something that we definitely need to investigate.

@marcj
Copy link
Member
marcj commented Apr 29, 2014

yepp, we could do it with https://github.com/mkraemer/react-inotify, but it requires indeed a pecl extension.

@CMCDragonkai
Copy link

Take a look at Facebook's watchman

@marcj
Copy link
Member
marcj commented Apr 29, 2014

@CMCDragonkai, why? It has nothing to do with PHP.

@CMCDragonkai
Copy link

Shell out to it, or integrate/port the C code?

@marcj
Copy link
Member
marcj commented Apr 29, 2014

What is wrong with react-inotify?

@CMCDragonkai
Copy link

@CMCDragonkai
Copy link

Nothing is wrong. Its just another implementation. But it supports more operating systems?

@camspiers
Copy link

In nodejs apps I usually have the master process actually spawn the workers (as processes), the master process can then listen to SIGHUP and gracefully restart the workers (always keeping at least one listening).

If using nginx you can configure it to failover down workers so your users don't see any downtime:

proxy_next_upstream error timeout http_500 http_502 http_503 http_504;

You can make your workers respond with a 502 after they have received SIGTERM but are still shutting down.

After this process the master will still have the old code (fine unless you have changed the masters code), but all the workers will have the new code.

In ubuntu for example, if you are using upstart, the reload command will send SIGHUP, and it can be called without sudo so you can easily call this as part of your automated deployment.

I haven't looked into this library a lot, but I understand that taking this approach would require changing architecture.

Here is a workerpool implementation in js https://gist.github.com/camspiers/075e2e22ca3d7a261d3e

@andig
Copy link
Contributor
andig commented Jun 4, 2015

Another approach could be a lifetime for our workers. Why not respawn them after x requests and/or time anyway? I'm not sure though that would reread php files where cached by code exists?

@hopeseekr
Copy link

I made some of the original hot code loading functionality in PHP, way way back in the PHP3 days. I ported the app to PHP 5.3, but it might be worth a look, even if I haven't actively worked on it in 13+ years ...?

http://phpegg.cvs.sourceforge.net/viewvc/phpegg/phpegg/source/mod_ctrl.inc?revision=1.2&view=markup

@andig
Copy link
Contributor
andig commented Nov 5, 2015

@hopeseekr I've looked at the link and can't see anything related to hot reloading?

@marcj
Copy link
Member
marcj commented Mar 17, 2016

Implemented in master, activated through debug option.

@marcj marcj closed this as completed Mar 17, 2016
@Koc
Copy link
Author
Koc commented Mar 18, 2016

@marcj can you give commit hash where this feature was added?

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

No branches or pull requests

7 participants
0