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

Track non-php files for workers restart? #376

Open
acasademont opened this issue Apr 24, 2018 · 8 comments
Open

Track non-php files for workers restart? #376

acasademont opened this issue Apr 24, 2018 · 8 comments

Comments

@acasademont
Copy link
Contributor

This a follow-up question to #348

Sometimes keeping track of PHP files is not enough. For example, a yaml config change in a symfony app does not trigger a restart of the slave workers, the yaml file change will indirectly trigger a change in the compiled php DI container (it checks for its freshnes at the beginning of a normal FPM request) but PHP-PM is obviously not able to notice it because it is already running. Maybe @AntonTyutin can help here?

@marcj
Copy link
Member

marcj commented Apr 24, 2018

For this use-case we have register_file, see

/**
* Adds a file path to the watcher list of PPM's master process.
*
* If you have a custom template engine, cache engine or something dynamic
* you probably want to call this function to let PPM know,
* that you want to restart all workers when this file has changed.
*
* @param string $path
*/
function register_file($path)
{
ProcessSlave::$slave->registerFile($path);
}

We use this method for Twig's template files.

@acasademont
Copy link
Contributor Author

Interesting, I guess this is something that could be added to the Symfony bootstrap class along with the twig files tracking @marcj ?

@andig
Copy link
Contributor

andig commented Apr 24, 2018

It could probably not in a general case- we simply don't know what config files you'd like to have watched. Or should we add any type of yaml?

@acasademont
Copy link
Contributor Author

Any file that lives within /config should trigger a reload, it could be yaml or xml or plain php. The bad thing is that there's no "getConfigDir" within the kernel interface, the "/config" is hardcoded in the standard Kernel.php file. Maybe an additional "track-files-dir" config option?

For now the best option is to extend the Symfony bootstrap class and manually register the config files using the method marc said

@marcj
Copy link
Member

marcj commented Apr 24, 2018

We should not implement a glob-like file watcher now. Instead, what we do with Twig is to hook into the postRequest handler and read in the twig-cache which template files it touched and register those using the method above. We should try to do the same with configuration files of any kind used by Symfony. However, I don't know if Symfony tracks them somewhere.

@marcj
Copy link
Member

marcj commented Apr 24, 2018

Actually, we could go the route with an argument like "--watch-dir config" which can be used multiple times. Then we need to figure out how to watch for changes on any OS which probably requires users to install some php extension. Not really great for UX tbh.

@acasademont
Copy link
Contributor Author

--watch-dir would be ideal, yes

@andig
Copy link
Contributor

andig commented Apr 25, 2018

This looks interesting for Linux: https://github.com/tsufeki/react-filesystem-monitor, I've also opened a ticket for OSX (tsufeki/react-filesystem-monitor#2)

@andig andig mentioned this issue Apr 27, 2018
3 tasks
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

3 participants