jc00ke / guard-puma

Restart puma when files change
MIT License
50 stars 19 forks source link

If puma crashes for some reason, it would never be restarted #22

Closed ioquatix closed 7 years ago

ioquatix commented 7 years ago

I'm editing config/puma.rb. If I make a mistake, puma would crash. I'd expect it to be reloaded once I fix the mistake, and it would be reloaded after I save the file. But, it's not. If I manually restart guard, it works.

Here is an example. I entered text asdf into config/puma.rb`, save, it crash, then I delete, and save, it won't restart.

[1] Development guard(main)> Puma starting in single mode...
* Version 3.6.2 (ruby 2.4.0-p0), codename: Sleepy Sunday Serenity
* Min threads: 0, max threads: 4
* Environment: development
* Inherited tcp://0.0.0.0:4000
* Starting control server on tcp://0.0.0.0:9293
Use Ctrl-C to stop
13:50:31 - INFO - Restarting Puma...

13:50:31 - INFO - Puma restarted
* Restarting...

[1] Development guard(main)> config/puma.rb:22:in `_load_from': undefined local variable or method `asdf' for #<Puma::DSL:0x00564f9ae5edf0> (NameError)
    from /home/samuel/.rvm/gems/ruby-2.4.0/gems/puma-3.6.2/lib/puma/dsl.rb:26:in `instance_eval'
    from /home/samuel/.rvm/gems/ruby-2.4.0/gems/puma-3.6.2/lib/puma/dsl.rb:26:in `_load_from'
    from /home/samuel/.rvm/gems/ruby-2.4.0/gems/puma-3.6.2/lib/puma/dsl.rb:9:in `load'
    from /home/samuel/.rvm/gems/ruby-2.4.0/gems/puma-3.6.2/lib/puma/configuration.rb:205:in `block in load'
    from /home/samuel/.rvm/gems/ruby-2.4.0/gems/puma-3.6.2/lib/puma/configuration.rb:202:in `each'
    from /home/samuel/.rvm/gems/ruby-2.4.0/gems/puma-3.6.2/lib/puma/configuration.rb:202:in `load'
    from /home/samuel/.rvm/gems/ruby-2.4.0/gems/puma-3.6.2/lib/puma/launcher.rb:62:in `initialize'
    from /home/samuel/.rvm/gems/ruby-2.4.0/gems/puma-3.6.2/lib/puma/cli.rb:65:in `new'
    from /home/samuel/.rvm/gems/ruby-2.4.0/gems/puma-3.6.2/lib/puma/cli.rb:65:in `initialize'
    from /home/samuel/.rvm/gems/ruby-2.4.0/gems/puma-3.6.2/bin/puma:8:in `new'
    from /home/samuel/.rvm/gems/ruby-2.4.0/gems/puma-3.6.2/bin/puma:8:in `<top (required)>'
    from /home/samuel/.rvm/gems/ruby-2.4.0/bin/puma:22:in `load'
    from /home/samuel/.rvm/gems/ruby-2.4.0/bin/puma:22:in `<main>'
13:50:31 - INFO - Restarting Puma...

13:50:31 - INFO - Puma NOT restarted, check your log files.

13:50:35 - INFO - Restarting Puma...

13:50:35 - INFO - Puma NOT restarted, check your log files.

13:50:36 - INFO - Restarting Puma...

13:50:36 - INFO - Puma NOT restarted, check your log files.

13:50:36 - INFO - Restarting Puma...

13:50:36 - INFO - Puma NOT restarted, check your log files.

[1] Development guard(main)> 
ioquatix commented 7 years ago

https://github.com/jc00ke/guard-puma/blob/fecd9d94d386b8831ac47b92b434e4803df85e9c/lib/guard/puma/runner.rb#L59-L65

Once puma has died, it can't be restarted. If the puma ctl can't be found, we should probably try to do a complete restart.