Giter Club home page Giter Club logo

guard-rack's Introduction

Guard::Rack

Gem Version Build Status Dependency Status Code Climate

Want to restart your Rack development with rackup whilst you work? Now you can!

guard 'rack', :port => 9292 do
  watch('Gemfile.lock')
  watch(%r{^(config|lib|app)/.*})
end

Options

  • :cmd is the command to run to mount the Rack application (default rackup).
  • :host is the host ip address to run on (default 0.0.0.0).
  • :port is the port number to run on (default 9292).
  • :environment is the environment to use (default development).
  • :start_on_start will start the server when starting Guard (default true).
  • :force_run kills any process that's holding open the listen port before attempting to (re)start Rack (default false).
  • :daemon runs the server as a daemon, without any output to the terminal that ran guard (default false).
  • :debugger runs the server with the debugger enabled (default false). Required ruby-debug gem.
  • :timeout waits this number of seconds when restarting the Rack server before reporting there's a problem (default 20).
  • :server serve using server (one of webrick, mongrel or thin).
  • :config run the specified rackup file (default config.ru).

Contributing

Fork the project. Make your feature addition or bug fix with tests. Send a pull request. Bonus points for topic branches.

Copyright and License

MIT License, see LICENSE for details.

(c) 2012-2019 Daniel Doubrovkine and Contributors.

guard-rack's People

Contributors

cristianbica avatar dashdotat avatar dblock avatar francocatena avatar jonyeezs avatar michaelherold avatar nerian avatar rubycut avatar tombh avatar viking avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

guard-rack's Issues

Doesn't work with Pry

It would be nice to use this with binding.pry, but though execution is halted on a binding.pry breakpoint, it doesn't seem to be possible to interact with Pry and even continue execution: most of the typed input gets ignored, so when e.g. typing continue, only something like ctne gets recognized by Pry.

Bundle Exec Support

Code should check for the presence of a Gemfile. If found, it should execute bundle exec rackup rather than rackup to ensure rack uses only the gems defined in the bundle.

Doesn't relaunch - ask me to terminate batch job 3 times

Running on windows 10.

This is my gemfile:

source 'https://rubygems.org'
ruby '2.1.7'

gem 'sinatra', require: 'sinatra/base'
gem 'thin'
gem 'activesupport', '~> 4.2', '>= 4.2.5', require: 'active_support/all'
gem 'json'
gem 'google_drive'

group :development do
  gem 'sinatra-contrib'
  gem 'win32console'
  gem 'wdm', '>= 0.1.0' if Gem.win_platform?
  gem 'guard'
  gem 'guard-rack'
  # gem 'rerun' works only on Unix
end

My GuardFile:

guard 'rack', port: 9292 do
  watch('Gemfile.lock')
  watch('config.ru')
  watch('server.rb')
  watch(%r{^config/.*})
  watch(%r{^app/(?!routes)([a-zA-Z]+)/.*}) # routes will be watched by sinatra::reloader
end

When i change a file i get this error:

Thin web server (v1.6.4 codename Gob Bluth)
Maximum connections set to 1024
Listening on 0.0.0.0:9292, CTRL+C to stop
127.0.0.1 - - [02/Apr/2016:00:09:00 +1000] "GET /budgets/year HTTP/1.1" 200 87 0.1421

00:09:29 - INFO - Restarting Rack...

^C^C^CTerminate batch job (Y/N)? Terminate batch job (Y/N)? Terminate batch job (Y/N)?

Undefined method “shutdown”

When I run Guard with -i/--no-interactions and then shutdown with Ctrl-C, following stack trace occurs:

Traceback (most recent call last):
	5: from /Users/franklinyu/.gem/ruby/2.5.5/gems/sinatra-2.0.5/lib/sinatra/main.rb:26:in `block in <module:Sinatra>'
	4: from (eval):1:in `run?'
	3: from /Users/franklinyu/.gem/ruby/2.5.5/gems/sinatra-2.0.5/lib/sinatra/main.rb:11:in `block in <class:Application>'
	2: from /Users/franklinyu/.gem/ruby/2.5.5/gems/sinatra-2.0.5/lib/sinatra/base.rb:1237:in `block in set'
	1: from /Users/franklinyu/.gem/ruby/2.5.5/gems/rack-2.0.6/lib/rack/server.rb:291:in `block in start'
/Users/franklinyu/.gem/ruby/2.5.5/gems/rack-2.0.6/lib/rack/handler/webrick.rb:48:in `shutdown': undefined method `shutdown' for nil:NilClass (NoMethodError)

Note that the process still exits. I’m just curious whether I should to worry about it.

Doesn't handle syntax errors so great?

I'm working with a Sinatra app, using guard-rack to monitor my config.ru file. This works fine.

However if I save the file with a typo, guard-rack tries to restart WEBrick and fails due to the syntax error.

22:16:24 - INFO - Rack restarted, pid 69
/bundler/ruby/2.7.0/gems/rack-2.2.3/lib/rack/builder.rb:116:in `eval': 
  /app/config.ru:24: syntax error, unexpected end-of-input, expecting `end' (SyntaxError)
# *** Stacktrace Snipped***

22:28:48 - INFO - Restarting Rack...

22:28:48 - INFO - Rackup exited with non-zero exit status (1) whilst trying to stop.
22:28:48 - INFO - Rack NOT restarted, check your log files.

(The log output from guard-rack happens after the failure from the child process.)

This situation isn't exactly ideal, because just fixing the typo does not restart rack again. I'm left in a state where I have to Ctrl-C the bundle exec guard and restart it. Which kind of feels like defeating the purpose. 😣

Am I missing some configuration option? I've looked at the source code and this behavior seems to be hard-coded:

UI.info 'Rack NOT restarted, check your log files.'

UI.info "Rackup exited with non-zero exit status (#{exitstatus}) whilst trying to stop."

Could not load 'guard/rack'

Hi,

I'm relatively new to Guard but have a good feel for how it works. I'm attempting to use Guard/Rack, but have been having a tough time getting it working. I've installed the gem, and when I attempt to run 'guard init', I get an error stating: "Could not load 'guard/rack'"

I could very possibly be missing something simple, and if that's the case I apologize in advance. However I did notice that the build status on your Github page is currently showing up as failed. I also noticed there were some commits made only a couple of hours ago so I didn't know if perhaps something broke in the process.

Regardless, any help is certainly appreciated. Please let me know if I can provide any additional information that would be helpful.

Thanks!

Server option?

It looks like the server option is dropped - it gets passed to the runner in the options hash, but the runner never uses it.

What was the intended use?

I could fork to add support for other servers. Thinking in particular of using unicorn's startup instead of rackup. The guard-unicorn gem is pretty tightly tied to unicorn_rails (among other limitations).

Guard deprecation warning from guard-rack code

    ******** BIG DEPRECATION WARNING !! ********

    Hi, Guard here.

    You're including lib/guard/guard.rb ...

    ... which contains code deprecated over a year ago!


    This file will likely be removed in the next version, so make sure you're
    not requiring it anywhere to ensure safe gem upgrades.

    If this message is annoying and you can't quickly fix the issue (see below),
    you have 2 options:

      1) Simply set the env variable "GUARD_GEM_SILENCE_DEPRECATIONS" to "1" to
      skip this message

      2) Freeze the gem to a previous version (not recommended because upgrades
      are cool and you might forget to unfreeze later!).

      E.g. in your Gemfile:

        if Time.now > Time.new(2014,11,10)
          gem 'guard', '~> 2.8'
        else
          # Freeze until 2014-11-10 - in case we forget to change back ;)
          gem 'guard', '= 2.7.3'
        end

    If you don't know which gem or plugin is requiring this file, here's a
    backtrace:

    gems/2.1.0/gems/guard-2.8.1/lib/guard/guard.rb:45:in `<module:Guard>'
     >> gems/2.1.0/gems/guard-2.8.1/lib/guard/guard.rb:3:in `<top (required)>'
     >> gems/2.1.0/gems/guard-rack-1.4.0/lib/guard/rack.rb:2:in `require'
     >> gems/2.1.0/gems/guard-rack-1.4.0/lib/guard/rack.rb:2:in `<top (required)>'
     >> gems/2.1.0/gems/guard-rack-1.4.0/lib/guard-rack.rb:1:in `require'"

Correct kill signal for stopping rackup?

Guard was taking a long time (30 or so seconds) to restart rackup, so I did some investigation and found that guard-rack was indeed killing the rack process, but was waiting for the pid file to be removed (which never happened), before it restarted. The MAX_WAIT_COUNT would however eventually kick in and restart rack.

Rack has an at_exit handler that removes its pid file, however that at_exit handler is triggered by the exit() that is fired by trapping the INT signal, not the KILL signal (see https://github.com/rack/rack/blob/master/lib/rack/server.rb#L257).

I've bug fixed a local fork of guard-rack by sending the INT signal instead. You can see the code I've changed here https://github.com/tombh/guard-rack/compare/change_kill_signal

Does anyone else suffer from this problem? Does this fix help anybody else? If it does I can write a test for my fix and submit it as a pull request.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.