roadrunner-server / roadrunner

🤯 High-performance PHP application server, process manager written in Go and powered with plugins
https://docs.roadrunner.dev
MIT License
7.92k stars 411 forks source link

Restart Workers on File Changes #102

Closed mnavarrocarter closed 5 years ago

mnavarrocarter commented 5 years ago

It would be pretty cool to include something that works like Nodemon in this library: a process that scans for *.php file changes in the root folder of the project and then restarts the workers if any change in code is encountered.

It could be optional and configurable in the yaml file. Suggestion:

hot-reload:
    enabled: true
    root_dir: ./ # relative to the rr.yaml file 
    rule: *.php # matches any php file.

I know a little bit of Go, so I could give it a try. I imagine the way to implement this is a goroutine that is dispatched every x seconds, checks for changes, and restarts the worker if any change is made.

wolfy-j commented 5 years ago

You can surely write module like that, or use existing solutions like i found here: https://github.com/fesor/life-without-orm/blob/master/etc/scripts/checkDeps.sh https://github.com/fesor/life-without-orm/blob/master/etc/scripts/devServer.sh

Alex-Bond commented 5 years ago

Beta version - https://github.com/UPDG/roadrunner-hotreload My version is not so optimized, but works good on any platforms.

AlexPravdin commented 5 years ago

When developing, you can use the PhpStorm IDE built-in File Watchers feature to run RR with http:reset key. It is very useful when working on Symfony app or similar, as RR should be restarted not only on .php files modification, but also yml and twig.

OO00O0O commented 5 years ago

I don't think that rr needs native file watcher. It should be kept simple. And http:reset is enough. There a lot of simple file watcher in wild already.

EDIT: I thought a little over the weekend about this, and I think that it would be beneficial for RR getting popular. And that means overall better open source project.

wolfy-j commented 5 years ago

Totally agreed.