Giter Club home page Giter Club logo

rerun's Introduction

Rerun

http://github.com/alexch/rerun

Rerun launches your program, then watches the filesystem. If a relevant file changes, then it restarts your program.

Rerun works for both long-running processes (e.g. apps) and short-running ones (e.g. tests). It's basically a no-frills command-line alternative to Guard, Shotgun, Autotest, etc. that doesn't require config files and works on any command, not just Ruby programs.

Rerun's advantage is its simple design. Since it uses exec and the standard Unix SIGINT and SIGKILL signals, you're sure the restarted app is really acting just like it was when you ran it from the command line the first time.

By default it watches files ending in: rb,js,coffee,css,scss,sass,erb,html,haml,ru,yml,slim,md,feature,c,h. Use the --pattern option if you want to change this.

As of version 0.7.0, we use the Listen gem, which tries to use your OS's built-in facilities for monitoring the filesystem, so CPU use is very light.

UPDATE: Now Rerun does work on Windows! Caveats:

  • not well-tested
  • you need to press Enter after keypress input
  • you may need to install the wdm gem manually: gem install wdm
  • You may see this persistent INFO error message; to remove it, use--no-notify:
    • INFO: Could not find files for the given pattern(s)

Installation:

    gem install rerun

("sudo" may be required on older systems, but try it without sudo first.)

If you are using RVM you might want to put this in your global gemset so it's available to all your apps. (There really should be a better way to distinguish gems-as-libraries from gems-as-tools.)

    rvm @global do gem install rerun

The Listen gem looks for certain platform-dependent gems, and will complain if they're not available. Unfortunately, Rubygems doesn't understand optional dependencies very well, so you may have to install extra gems (and/or put them in your Gemfile) to make Rerun work more smoothly on your system. (Learn more at https://github.com/guard/listen#listen-adapters.)

On Mac OS X, use

    gem install rb-fsevent

On Windows, use

    gem install wdm

On *BSD, use

    gem install rb-kqueue

Installation via Gemfile / Bundler

If you are using rerun inside an existing Ruby application (like a Rails or Sinatra app), you can add it to your Gemfile:

group :development, :test do
  gem "rerun"
end

Using a Gemfile is also an easy way to use the pre-release branch, which may have bugfixes or features you want:

group :development, :test do
  gem "rerun", git: "https://github.com/alexch/rerun.git"
end

When using a Gemfile, install with bundle install or bundle update, and run using bundle exec rerun, to guarantee you are using the rerun version specified in the Gemfile, and not a different version in a system-wide gemset.

Usage:

    rerun [options] [--] cmd

For example, if you're running a Sinatra app whose main file is app.rb:

    rerun ruby app.rb

If the first part of the command is a .rb filename, then ruby is optional, so the above can also be accomplished like this:

    rerun app.rb

Rails doesn't automatically notice all config file changes, so you can force it to restart when you change a config file like this:

    rerun --dir config rails s

Or if you're using Thin to run a Rack app that's configured in config.ru but you want it on port 4000 and in debug mode, and only want to watch the app and web subdirectories:

    rerun --dir app,web -- thin start --debug --port=4000 -R config.ru

The -- is to separate rerun options from cmd options. You can also use a quoted string for the command, e.g.

    rerun --dir app "thin start --debug --port=4000 -R config.ru"

Rackup can also be used to launch a Rack server, so let's try that:

    rerun -- rackup --port 4000 config.ru

Want to mimic autotest? Try

    rerun -x rake

or

    rerun -cx rspec

And if you're using Spork with Rails, you need to restart your spork server whenever certain Rails environment files change, so why not put this in your Rakefile...

desc "run spork (via rerun)"
task :spork do
  sh "rerun --pattern '{Gemfile,Gemfile.lock,spec/spec_helper.rb,.rspec,spec/factories/**,config/environment.rb,config/environments/test.rb,config/initializers/*.rb,lib/**/*.rb}' -- spork"
end

and start using rake spork to launch your spork server?

(If you're using Guard instead of Rerun, check out guard-spork for a similar solution.)

How about regenerating your HTML files after every change to your Erector widgets?

    rerun -x erector --to-html my_site.rb

Use Heroku Cedar? rerun is now compatible with foreman. Run all your Procfile processes locally and restart them all when necessary.

    rerun foreman start

Options:

These options can be specified on the command line and/or inside a .rerun config file (see below).

--dir directory (or directories) to watch (default = "."). Separate multiple paths with ',' and/or use multiple -d options.

--pattern glob to match inside directory. This uses the Ruby Dir glob style -- see http://www.ruby-doc.org/core/classes/Dir.html#M002322 for details. By default it watches files ending in: rb,js,coffee,css,scss,sass,erb,html,haml,ru,yml,slim,md,feature,c,h. On top of this, it also ignores dotfiles, .tmp files, and some other files and directories (like .git and log). Run rerun --help to see the actual list.

--ignore pattern file glob to ignore (can be set many times). To ignore a directory, you must append '/*' e.g. --ignore 'coverage/*'.

--[no-]ignore-dotfiles By default, on top of --pattern and --ignore, we ignore any changes to files and dirs starting with a dot. Setting --no-ignore-dotfiles allows you to monitor a relevant file like .env, but you may also have to explicitly --ignore more dotfiles and dotdirs.

--signal (or -s) use specified signal(s) (instead of the default TERM,INT,KILL) to terminate the previous process. You can use a comma-delimited list if you want to try a signal, wait up to 5 seconds for the process to die, then try again with a different signal, and so on. This may be useful for forcing the respective process to terminate as quickly as possible. (--signal KILL is the equivalent of kill -9)

--wait sec (or -w) after asking the process to terminate, wait this long (in seconds) before either aborting, or trying the next signal in series. Default: 2 sec

--restart (or -r) expect process to restart itself, using signal HUP by default (e.g. -r -s INT will send a INT and then resume watching for changes)

--exit (or -x) expect the program to exit. With this option, rerun checks the return value; without it, rerun checks that the launched process is still running.

--clear (or -c) clear the screen before each run

--background (or -b) disable on-the-fly commands, allowing the process to be backgrounded

--notify NOTIFIER use growl or osx or notify-send for notifications (see below)

--no-notify disable notifications

--name set the app name (for display)

--force-polling use polling instead of a native filesystem scan (useful for Vagrant)

--quiet silences most messages

--verbose enables even more messages (unless you also specified --quiet, which overrides --verbose)

Also --version and --help, naturally.

Config file

If the current directory contains a file named .rerun, it will be parsed with the same rules as command-line arguments. Newlines are the same as any other whitespace, so you can stack options vertically, like this:

--quiet
--pattern **/*.{rb,js,scss,sass,html,md}

Options specified on the command line will override those in the config file. You can negate boolean options with --no-, so for example, with the above config file, to re-enable logging, you could say:

rerun --no-quiet rackup

If you're not sure what options are being overwritten, use --verbose and rerun will show you the final result of the parsing.

Notifications

If you have growlnotify available on the PATH, it sends notifications to growl in addition to the console.

If you have terminal-notifier, it sends notifications to the OS X notification center in addition to the console.

If you have notify-send, it sends notifications to Freedesktop-compatible desktops in addition to the console.

If you have more than one available notification program, Rerun will pick one, or you can choose between them using --notify growl, --notify osx, --notify notify-send, etc.

If you have a notifier installed but don't want rerun to use it, set the --no-notify option.

Download growlnotify here now that Growl has moved to the App Store.

Install terminal-notifier using gem install terminal-notifier. (You may have to put it in your system gemset and/or use sudo too.) Using Homebrew to install terminal-notifier is not recommended.

On Debian/Ubuntu, notify-send is available in the libnotify-bin package. On other GNU/Linux systems, it might be in a package with a different name.

On-The-Fly Commands

While the app is (re)running, you can make things happen by pressing keys:

  • r -- restart (as if a file had changed)
  • f -- force restart (stop and start)
  • c -- clear the screen
  • x or q -- exit (just like control-C)
  • p -- pause/unpause filesystem watching

If you're backgrounding or using Pry or a debugger, you might not want these keys to be trapped, so use the --background option.

Signals

The current algorithm for killing the process is:

  • send SIGTERM (or the value of the --signal option)
  • if that doesn't work after 2 seconds, send SIGINT (aka control-C)
  • if that doesn't work after 2 more seconds, send SIGKILL (aka kill -9)

This seems like the most gentle and unixy way of doing things, but it does mean that if your program ignores SIGTERM, it takes an extra 2 to 4 seconds to restart.

If you want to use your own series of signals, use the --signal option. If you want to change the delay before attempting the next signal, use the --wait option.

Vagrant and VirtualBox

If running inside a shared directory using Vagrant and VirtualBox, you must pass the --force-polling option. You may also have to pass some extra --ignore options too; otherwise each scan can take 10 or more seconds on directories with a large number of files or subdirectories underneath it.

Troubleshooting

zsh

If you are using zsh as your shell, and you are specifying your --pattern as **/*.rb, you may face this error

Errno::EACCES: Permission denied - <filename>

This is because **/*.rb gets expanded into the command by zsh instead of passing it through to rerun. The solution is to simply quote ('' or "") the pattern. i.e

rerun -p **/*.rb rake test

becomes

rerun -p "**/*.rb" rake test

To Do:

Must have for v1.0

  • Make sure to pass through quoted options correctly to target process [bug]
  • Optionally do "bundle install" before and "bundle exec" during launch

Nice to have

  • ".rerun" file in $HOME
  • If the last element of the command is a .ru file and there's no other command then use rackup
  • Figure out an algorithm so "-x" is not needed (if possible) -- maybe by accepting a "--port" option or reading config.ru
  • Specify (or deduce) port to listen for to determine success of a web server launch
  • see also todo.md

Wacky Ideas

  • On OS X:
    • use a C library using growl's developer API http://growl.info/developer/
    • Use growl's AppleScript or SDK instead of relying on growlnotify
    • "Failed" icon for notifications

Other projects that do similar things

Why would I use this instead of Shotgun?

Shotgun does a "fork" after the web framework has loaded but before your application is loaded. It then loads your app, processes a single request in the child process, then exits the child process.

Rerun launches the whole app, then when it's time to restart, uses "kill" to shut it down and starts the whole thing up again from scratch.

So rerun takes somewhat longer than Shotgun to restart the app, but does it much less frequently. And once it's running it behaves more normally and consistently with your production app.

Also, Shotgun reloads the app on every request, even if it doesn't need to. This is fine if you're loading a single file, but if your web pages all load other files (CSS, JS, media) then that adds up quickly. (I can only assume that the developers of shotgun are using caching or a front web server so this isn't a pain point for them.)

And hey, does Shotgun reload your Worker processes if you're using Foreman and a Procfile? I'm pretty sure it doesn't.

YMMV!

Why would I use this instead of Rack::Reloader?

Rack::Reloader is certifiably beautiful code, and is a very elegant use of Rack's middleware architecture. But because it relies on the LOADED_FEATURES variable, it only reloads .rb files that were 'require'd, not 'load'ed. That leaves out (non-Erector) template files, and also, at least the way I was doing it, sub-actions (see this thread).

Rack::Reloader also doesn't reload configuration changes or redo other things that happen during app startup. Rerun takes the attitude that if you want to restart an app, you should just restart the whole app. You know?

Why would I use this instead of Guard?

Guard is very powerful but requires some up-front configuration. Rerun is meant as a no-frills command-line alternative requiring no knowledge of Ruby nor config file syntax.

Why did you write this?

I've been using Sinatra and loving it. In order to simplify their system, the Rat Pack removed auto-reloading from Sinatra proper. I approve of this: a web application framework should be focused on serving requests, not on munging Ruby ObjectSpace for dev-time convenience. But I still wanted automatic reloading during development. Shotgun wasn't working for me (see above) so I spliced Rerun together out of code from Rspactor, FileSystemWatcher, and Shotgun -- with a heavy amount of refactoring and rewriting. In late 2012 I migrated the backend to the Listen gem, which was extracted from Guard, so it should be more reliable and performant on multiple platforms.

Credits

Rerun: Alex Chaffee, mailto:[email protected], http://github.com/alexch/

Based upon and/or inspired by:

Patches by:

Version History

  • v0.14.0 4 January 2023

    • Ruby 3.2 compatibility fix: .exists? no longer exists
  • v0.13.1 9 December 2020

    • --no-ignore-dotfiles option
  • v0.13.0 26 January 2018

    • bugfix: pause/unpause works again (thanks Barry!)
    • .rerun config file
  • v0.12.0 23 January 2018

    • smarter --signal option, allowing you to specify a series of signals to try in order; also --wait to change how long between tries
    • --force-polling option (thanks ajduncan)
    • f key to force stop and start (thanks mwpastore)
    • add .c and .h files to default ignore list
    • support for Windows
      • use Kernel.spawn instead of fork
      • use wdm gem for Windows Directory Monitor
    • support for notifications on GNU/Linux using notify-send (thanks terceiro)
    • fix Gem::LoadError - terminal-notifier is not part of the bundle bug (thanks mattheworiordan)
  • 0.11.0 7 October 2015

    • better 'changed' message
    • --notify osx option
    • --restart option (with bugfix by Mike Pastore)
    • use Listen 3 gem
    • add .feature files to default watchlist (thanks @jmuheim)
  • v0.10.0 4 May 2014

    • add '.coffee,.slim,.md' to default pattern (thanks @xylinq)
    • --ignore option
  • v0.9.0 6 March 2014

    • --dir (or -d) can be specified more than once, for multiple directories (thanks again Barry!)
    • --name option
    • press 'p' to pause/unpause filesystem watching (Barry is the man!)
    • works with Listen 2 (note: needs 2.3 or higher)
    • cooldown works, thanks to patches to underlying Listen gem
    • ignore all dotfiles, and add actual list of ignored dirs and files
  • v0.8.2

    • bugfix, forcing Rerun to use Listen v1.0.3 while we work out the troubles we're having with Listen 1.3 and 2.1
  • v0.8.1

    • bugfix release (#30 and #34)
  • v0.8.0

    • --background option (thanks FND!) to disable the keyboard listener
    • --signal option (thanks FND!)
    • --no-growl option
    • --dir supports multiple directories (thanks Barry!)
  • v0.7.1

    • bugfix: make rails icon work again
  • v0.7.0

    • uses Listen gem (which uses rb-fsevent for lightweight filesystem snooping)

License

Open Source MIT License. See "LICENSE" file.

rerun's People

Contributors

ajduncan avatar alexch avatar anbotero avatar avdi avatar bjvanminnen avatar bsia avatar bsingr avatar ccoveille avatar dreamcat4 avatar edwardbetts avatar eloyesp avatar fnd avatar fukayatsu avatar gtramontina avatar jeg2 avatar jjoos avatar krissi avatar ktaragorn avatar manuelmorales avatar mattbrictson avatar mattheworiordan avatar misfo avatar mwpastore avatar nixme avatar robkinyon avatar terceiro avatar thiagokokada avatar xylinq 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

rerun's Issues

Add the ability to prewarm a command rerun will run

Web apps can take a few seconds to startup. For these apps, when used with rerun, the developer experience isn't great -- after making a change, the server will be down for a few seconds as rerun restarts it. This is annoying for workflows where you're immediately running integration tests after a change or previewing the changes in a browser window right away.

What I'll probably try in the short term is to write a daemon which does some initialization work (like requiring expensive gems) and then fork the webapp. I'll then have rerun send that script signals when files change which will cause a refork.

I don't know of a good solution that fits within the clean scope of rerun, but I wanted to see if you had any ideas. It would be nice if rerun provided some assistance solving this problem, like allowing you to specify a pre-fork and post-fork script (assuming they're both in Ruby).

Option to disable your c and r polling.

It would be nice if you give us the option to disable those commands and the polling that comes with them so that you do not pretty much ruin Pry sessions. Sometimes in development I like to test ideas and read params as they come in and when you are polling it's absolutely impossible to work with Pry.

Vote for the "cool-down" feature

Just a note to register a strong vote for the cool-down feature. This is working really nicely to help with restarting a Rails 3 Grape API app I'm working on. But I use RubyMine, which autosaves all the time, and this causes rerun to kick off constantly. It would even be cool if you kept it simple and we could start rerun with a flag telling it to not restart more than once every X seconds. Thanks for the great program.

"rerun foreman start", the first re-run fails with "Errno::EADDRINUSE" (Ubuntu 12.10)

rerun foreman start

17:31:47 [rerun] Heroku.dev launched
17:31:47 web.1  | started with pid 22808
17:31:49 web.1  | [2013-07-03 17:31:49] INFO  WEBrick 1.3.1
17:31:49 web.1  | [2013-07-03 17:31:49] INFO  ruby 1.9.3 (2012-04-20) [x86_64-linux]
17:31:49 web.1  | [2013-07-03 17:31:49] INFO  WEBrick::HTTPServer#start: pid=22811 port=5000
17:31:50 [rerun] Watching . for **/*.{rb,js,css,scss,sass,erb,html,haml,ru} using Linux adapter
r17:31:56 [rerun] Restarting
17:31:56 [rerun] Sending signal TERM to 22799
SIGTERM received
17:31:56 system | sending SIGTERM to all processes
17:32:00 [rerun] Sending signal INT to 22799
SIGINT received
17:32:01 system | sending SIGKILL to all processes
17:32:02 [rerun] Sending signal KILL to 22799

17:32:02 [rerun] Heroku.dev restarted
17:32:02 web.1  | started with pid 22892
17:32:04 web.1  | [2013-07-03 17:32:04] INFO  WEBrick 1.3.1
17:32:04 web.1  | [2013-07-03 17:32:04] INFO  ruby 1.9.3 (2012-04-20) [x86_64-linux]
17:32:04 web.1  | [2013-07-03 17:32:04] WARN  TCPServer Error: Address already in use - bind(2)
17:32:04 web.1  | /usr/lib/ruby/1.9.1/webrick/utils.rb:85:in `initialize': Address already in use - bind(2) (Errno::EADDRINUSE)
17:32:04 web.1  |   from /usr/lib/ruby/1.9.1/webrick/utils.rb:85:in `new'
17:32:04 web.1  |   from /usr/lib/ruby/1.9.1/webrick/utils.rb:85:in `block in create_listeners'
17:32:04 web.1  |   from /usr/lib/ruby/1.9.1/webrick/utils.rb:82:in `each'
17:32:04 web.1  |   from /usr/lib/ruby/1.9.1/webrick/utils.rb:82:in `create_listeners'
17:32:04 web.1  |   from /usr/lib/ruby/1.9.1/webrick/server.rb:82:in `listen'
17:32:04 web.1  |   from /usr/lib/ruby/1.9.1/webrick/server.rb:70:in `initialize'
17:32:04 web.1  |   from /usr/lib/ruby/1.9.1/webrick/httpserver.rb:45:in `initialize'
17:32:04 web.1  |   from /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/handler/webrick.rb:11:in `new'
17:32:04 web.1  |   from /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/handler/webrick.rb:11:in `run'
17:32:04 web.1  |   from /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/server.rb:264:in `start'
17:32:04 web.1  |   from /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/server.rb:141:in `start'
17:32:04 web.1  |   from /var/lib/gems/1.9.1/gems/rack-1.5.2/bin/rackup:4:in `<top (required)>'
17:32:04 web.1  |   from /usr/local/bin/rackup:23:in `load'
17:32:04 web.1  |   from /usr/local/bin/rackup:23:in `<main>'
17:32:04 web.1  | exited with code 1
17:32:04 system | sending SIGTERM to all processes

"foreman" recieve SIGKILL, so "rackup" not killed by "foreman" (i can see it in a process list on port 5000), so "foreman" can't start second time.

Maybe time intervals between signals should be in options?

Don't use growl by default

...otherwise one always has to specify --no-growl, or one has to live with this on every call:

2014-03-20 11:30:07.649 growlnotify[81048:507] Got disconnected: Error Domain=NSPOSIXErrorDomain Code=61 "Connection refused" UserInfo=0x7fd5e1505010 {NSLocalizedDescription=Connection refused, NSLocalizedFailureReason=Error in connect() function}
2014-03-20 11:30:07.650 growlnotify[81048:507] <GrowlGNTPRegistrationAttempt: 0x7fd5e1504660> failed because Error Domain=NSPOSIXErrorDomain Code=61 "Connection refused" UserInfo=0x7fd5e1505010 {NSLocalizedDescription=Connection refused, NSLocalizedFailureReason=Error in connect() function}
2014-03-20 11:30:07.651 growlnotify[81048:507] Failed to register with (null)

Optional features should be opt-in.

No such file or directory - app.rb

When I start my app with:

rerun app.rb

I get the following error:

No such file or directory - app.rb

Which doesn't really make any sense… I am in the directory with app.rb…

Any ideas?

Monitoring shared directories inside a vagrant VM doesn't work

We're trying to use rerun to automatically restart a sinatra process inside a vagrant VM (ubuntu). The host is a Mac, and the source tree is in a shared directory. rerun starts, but doesn't detect changes on the files in the source tree.

Is there a way to get this to work? Is this a more appropriate issue for the listen gem?

--background flag only works on initial load

I'm utilizing the --background flag to drop into a pry debugger and still have it be responsive. This works well the first time the sinatra server is loaded however each subsequent reload the pry console fails to display what is typed (the same behavior as when I run the sinatra server without the --background flag).

Is this a bug or am I missing some configuration?

I'm using ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux] and rerun 0.10.0.

Support multiple directories

For gem developers, it's often impossible to have all files in a single directory.

The ability to specify multiple directories to watch would be invaluable

Monitor ../directory

I've got a projects folder with a layout like:
Projects/
─ rails_admin/
─ api-project/

My api-project directory contains a standard rails project, and rails_admin is a fork of the rails_admin gem that I work on locally, and that I include via path sometimes in my Gemfile.

I think it'd be really cool if I could essentially do:

bundle exec rerun --background --dir app,lib --dir ../rails_admin/app --dir ../rails_admin/lib -- bundle exec rails s -p 3002 -P tmp/pids/admin.pid -e development_admin

... while inside the api-project folder, so that whenever I make changes to my local copy of the rails_admin gem, my rails server gets restarted.

I attempted to do this by starting my server via rerun with the above command, but it doesn't seem to be working in the way I'd hope it might, i.e., if I edit a file within the rails_admin directory that it ought to restart the server. I'm not sure why this wouldn't work, and I assume I'm running into a fairly rare and unintended use-case. But I guess it doesn't hurt to ask– is there any obvious thing I might simply be doing wrong or missing? I'm not very familiar with how this filesystem monitoring stuff works, but I'd be glad to try to help implement this feature if there's not perhaps some obvious reason why it's technically unfeasible.

Thanks!

Undefined method 'version' for nil:NilClass

Nathanaels-MacBook-Pro:resizer-web nathanael$ bundle exec rerun --dir '.' --pattern "**/*.{rb,slim,js,yml,css,less,scss,sass,erb,html,htmf,haml,ru,haml,md,mdown,markdown}" -- thin start --debug --port=4001
/Users/nathanael/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/bundler/gems/rerun-31d6a11b5269/lib/rerun/options.rb:25:in `block in parse': undefined method `version' for nil:NilClass (NoMethodError)
  from /Users/nathanael/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/optparse.rb:882:in `initialize'
  from /Users/nathanael/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/bundler/gems/rerun-31d6a11b5269/lib/rerun/options.rb:19:in `new'
  from /Users/nathanael/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/bundler/gems/rerun-31d6a11b5269/lib/rerun/options.rb:19:in `parse'
  from /Users/nathanael/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/bundler/gems/rerun-31d6a11b5269/bin/rerun:10:in `<top (required)>'
  from /Users/nathanael/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/bin/rerun:23:in `load'
  from /Users/nathanael/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/bin/rerun:23:in `<main>'

Integrate with .gitignore

Git received a check-ignore command in version 1.8.2, which allows for easy testing whether a given file is gitignored:

ruby 2.0.0p247 > irb
[1] pry(main)> system "git check-ignore coverage/index.html"
coverage/index.html
=> true
[2] pry(main)> system "git check-ignore config/boot.rb"
=> false

I think it would be very useful if there was an option to rerun based solely on whether the changed file is under version control. This would work well in conjunction with a pattern of '*/' - every time some file under version control changes, rerun.

Invalid date format in specification

I recently made a Pull Request, since I thought the errors I was getting were because of that, but it seems that wasn't the cause.

I'm getting these errors while trying to update the gem:

Invalid gemspec in [/Users/myusername/.rvm/gems/ruby-1.9.2-head@myproject/specifications/rerun-0.6.1.gemspec]: invalid date format in specification: "2011-05-16 00:00:00.000000000Z" /Users/myusername/.rvm/rubies/ruby-1.9.2-head/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:277:inblock in _resort!': undefined method name' for nil:NilClass (NoMethodError) from /Users/myusername/.rvm/rubies/ruby-1.9.2-head/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:276:insort!'
from /Users/myusername/.rvm/rubies/ruby-1.9.2-head/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:276:in _resort!' from /Users/myusername/.rvm/rubies/ruby-1.9.2-head/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:270:in_all'
from /Users/myusername/.rvm/rubies/ruby-1.9.2-head/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:402:in each' from /Users/myusername/.rvm/rubies/ruby-1.9.2-head/lib/ruby/site_ruby/1.9.1/rubygems.rb:477:inmap'
from /Users/myusername/.rvm/rubies/ruby-1.9.2-head/lib/ruby/site_ruby/1.9.1/rubygems.rb:477:in find_files' from /Users/myusername/.rvm/rubies/ruby-1.9.2-head/lib/ruby/site_ruby/1.9.1/rubygems.rb:1061:inload_plugins'
from /Users/myusername/.rvm/rubies/ruby-1.9.2-head/lib/ruby/site_ruby/1.9.1/rubygems/gem_runner.rb:86:in <top (required)>' from /Users/myusername/.rvm/rubies/ruby-1.9.2-head/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:inrequire'
from /Users/myusername/.rvm/rubies/ruby-1.9.2-head/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in require' from /Users/myusername/.rvm/rubies/ruby-1.9.2-head/bin/gem:9:in

'`

No idea what's going on, really, I checked with other gems and, well, the only difference is that their generated .gemspec doesn't specify the time, just the date. Thanks, and keep it up!

Support for a --exclude option

I'm using Rerun for for Python development with Heroku. (Long story short, the HTTP server I use in production doesn't support automatic-reloading, so I have rerun kicking foreman when there are code changes).

I use Emacs for development, with flymake mode to do on-the-fly syntax checking. It does this by copying the current buffer into a [filename]_flymake.py file and then running pylint on that file. This file creation kicks off rerun, so it's constantly bouncing my development HTTP server as I'm editing code.

I'd like to add my vote for a --exclude option that can take a glob pattern. I'd send you a pull myself, but I don't know enough Ruby.

Cheers

Rerun a Proc

I noticed that Runner#new take a string command to pass to exec. Maybe it's a good idea let the Runner to manage also a Proc or block, so we can trigger pure ruby code instead of a shell command. Isn't it?

GrowlNotify for Growl >= 1.3

Hi all.

As pointed in readme I want to let you know that growlnotify is available for Growl >= 1.3. As pointed out on your own link, growlnotify 1.3, for use with Growl 1.3, is available at this address, and works fine with rerun.

feature: hit 'space' to restart

Sometimes I edit a file that's not in the pattern and I want to restart anyway. Hitting 'r' or 'space' should trigger a restart. Now I have to do "control-C !! return" which isn't a major trauma but still.

Also 'c' should do the same with a clear screen (even if -c wasn't originally specified).

add option to force-restart immediately

For some scenarios (e.g. restarting a development web server), you don't need to be gentle - so kill -9 is a valid option to speed up the restart process.

Thus it'd be nice if there was an option to make this line use SIGKILL (or perhaps an aribtrary signal) instead of SIGTERM.

control-C during restart leaves something running

the signal handler should not only kill a running process; it should also kill a process that we're currently in the middle of starting (if the timing is just wrong it'll leave one running in the background)

stty: standard input: unable to perform all requested operations

Any idea what outputs the following into the console when running rerun?
"stty: standard input: unable to perform all requested operations"

I'm running on OS X Maverick, ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0] with rbenv and homebrew.

Everything works just fine, but the console gets filled with the warning.

Here is the log:

rerun --dir .,data,lib,views -- unicorn -E development

00:58:09 [rerun] App launched
stty: standard input: unable to perform all requested operations
I, [2014-06-14T00:58:10.137072 #28734]  INFO -- : listening on addr=0.0.0.0:8080 fd=9
I, [2014-06-14T00:58:10.137220 #28734]  INFO -- : worker=0 spawning...
I, [2014-06-14T00:58:10.138324 #28734]  INFO -- : master process ready
I, [2014-06-14T00:58:10.139132 #28736]  INFO -- : worker=0 spawned pid=28736
I, [2014-06-14T00:58:10.139568 #28736]  INFO -- : Refreshing Gem list
I, [2014-06-14T00:58:10.421355 #28736]  INFO -- : worker=0 ready
stty: standard input: unable to perform all requested operations
stty: standard input: unable to perform all requested operations
00:58:12 [rerun] Watching data, lib, views for **/*.{rb,js,coffee,css,scss,sass,erb,html,haml,ru,yml,slim,md} using Darwin adapter
stty: standard input: unable to perform all requested operations
stty: standard input: unable to perform all requested operations
stty: standard input: unable to perform all requested operations
stty: standard input: unable to perform all requested operations
^Crake aborted!
Interrupt:

Ability to "rerun" different commands under the same rerun thread...

Hi Alex. This isn't really an issue, but a question/request. I love rerun and glad to have discovered it after using shotgun for a long time. Anyway, I'm finding that it might be useful to define a rerun config that defines different file pattern matches and associate different commands to it. For example, I might want to rerun rackup if my *.rb and *.ru changes, but might want to run a custom js/css minifier build script if I change a *.js/css.

I'm going to fork rerun and see if this is possible, but just thought I'd ask if you've thought of baking this into rerun... or if it's even possible.

Thanks!

support libnotify for popup notifications on linux

Popup notifications using libnotify are common on linux. One would need a notification daemon running like gnome's notification-daemon, dunst, etc..

There is a libnotify gem by Peter Suschlik that works well with my setup using dunst. This gem depends on the ffi gem to call C functions from libnotify.

Windows error: uninitialized constant MissingSourceFile

When I run rerun on Windows, I get the following:

E:/lib/ruby/gems/1.8/gems/rerun-0.2.1/lib/system.rb:7: uninitialized constant MissingSourceFile (NameError)
from E:/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require' from E:/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from E:/lib/ruby/gems/1.8/gems/rerun-0.2.1/lib/rerun.rb:1
from E:/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require' from E:/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from E:/lib/ruby/gems/1.8/gems/rerun-0.2.1/bin/rerun:48
from E:/bin/rerun:19:in `load'
from E:/bin/rerun:19

-q "Quiet" mode to not call growlnotify

I'd like to keep growlnotify in my path (for reasons not related to rerun) but not have rerun tell me every time it reruns.

So it'd be cool to have a -q (quiet) mode that doesn't look for growlnotify at all.

Stop rerun when launch failed

I think that rerun should exit when it can't launch the app:

15:55:22 [rerun] Synaesthesia Launch Failed
15:55:23 [rerun] Watching . for {Gemfile.lock,config/environment.rb,config/environments/development.rb,config/initializers/*.rb,lib/**/*.rb} using Darwin adapter

Or do you expect the next time the launch will succeed?

Allow monitoring of changes to files starting with a dot

I'm trying to get rerun to pick up changes to my .env file, used with Foreman. Restarting my server when code changes is working just fine, but ideally I'd like to have a workflow where I can change environment vars in .env and have the app auto-reload with new configuration.

I see that this is a deliberate built-in feature of the file globbing implementation. Turning this off could be a switch (e.g. --no-ignore-dot) or perhaps an implementation of the exclude option #24 could have leading dots, etc. as the default value, which could then be overridden.

I'm happy to give a shot at implementing this myself. Just wondering if it's already in progress or if you're opposed to the idea.

Rerun used to work.. doesn't anymore... I haven't changed my command or directory structure.. What's up?

Here's the command I'm using to start my application.

mkdir -p tmp/pids && rerun --background -- bundle exec sidekiq -r ./main.rb -e development -C ./config/sidekiq.yml --verbose

I run this from the root of my project.

The application starts as expects but when files are changed it does not restart.

Here are my versions..

OSX: 10.10.3
Ruby: 2.1.5p273
Gem Versions: 
  rb-fsevent (0.9.4)
  rerun (0.10.0)
  rvm (1.11.3.9)
  sidekiq (3.2.5)
  sidekiq-pro (1.9.0)

doesn't work on ruby trunk

It exits right after the first run:

[~/Workspace/ruby/ext/strscan]$ rerun -x make              [trunk][2.1.0-dev]
2013-04-28 14:59:10.576 growlnotify[41046:707] Failed to register with (null)

14:59:10 [rerun] Strscan launched
installing default strscan libraries
2013-04-28 14:59:12.649 growlnotify[41073:707] Failed to register with (null)

14:59:12 [rerun] Strscan succeeded
[Listen warning]:
Listen::MultiListener is deprecated, please use Listen::Listener instead.
14:59:13 [rerun] Watching ["."]/**/*.{rb,js,css,scss,sass,erb,html,haml,ru}
using Darwin adapter
[~/Workspace/ruby/ext/strscan]$

Exit code is 0.

Adjustable app_name?

We use rerun not just to reboot a single app server but a set of different processes that are part of the same app but have different dependencies (via --pattern).

Unfortunately the log message and growlnotify always use the parent folder name.

Would you be open to a patch for a -n name type of option?

tell me when the server is listening

if possible, detect when the server has not only launched but is listening to the port and ready to accept requests

this may require some config.ru snooping or CL params to figure out what port to check

--pattern mixed with --dir

Looks like a typo - here's the fix:

opts.on("-p pattern", "--pattern pattern", "file glob, default = "#{Rerun::DEFAULT_PATTERN}"") do |pattern|
options[:pattern] = pattern
end

(vs options[:dir])

Doesn't work when source file is mounted from Mac OSX

The source file is in mac osx. I mount the dir to a Linux which is in a vmware virtual machine. In linux, I try to "rerun 'rackup'", the server can be started up, but when I change the source file on Mac OS X, the server doesn't auto reload. When I change the source file on linux, It works great. How can I resolve this problem?

What am I doing wrong with these options?

I want to run the comment pandoc examples/code.md -f markdown -o code.pdf && open code.pdf whenever the file examples/code.md is changed.

Sadly, this somehow doesn't work:

$ rerun --pattern '{*.md}' -- pandoc examples/code.md -f markdown -o code.pdf && open code.pdf

10:31:03 [rerun] Pandoc-test launched

10:31:05 [rerun] Pandoc-test Launch Failed
10:31:05 [rerun] Watching . for {*.md} using Darwin adapter
^C
10:32:51 [rerun] Pandoc-test stopping
10:32:51 [rerun] Sending signal TERM to 30896

The pdf is only generated and opened when I send ^C signal. What to do?

License missing from gemspec

RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.

via e.g.

spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']

Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.

There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.

I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!

Appendix:

If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies

p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.

FATAL SignalException: SIGTERM

I try to restart webrick whenever an important file changes. This is the output:

=> Booting WEBrick
=> Rails 4.0.3 application starting in development on http://0.0.0.0:3001
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2014-03-19 09:38:13] INFO  WEBrick 1.3.1
[2014-03-19 09:38:13] INFO  ruby 2.1.0 (2013-12-25) [x86_64-darwin12.0]
[2014-03-19 09:38:13] INFO  WEBrick::HTTPServer#start: pid=9912 port=3001
r09:38:31 [rerun] Restarting
09:38:31 [rerun] Sending signal TERM to 9912
[2014-03-19 09:38:31] FATAL SignalException: SIGTERM
    /Users/josh/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/webrick/server.rb:170:in `select'
    /Users/josh/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/webrick/server.rb:170:in `block in start'
    /Users/josh/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/webrick/server.rb:32:in `start'
    /Users/josh/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/webrick/server.rb:160:in `start'
    /Users/josh/.rvm/gems/ruby-2.1.0@base/gems/rack-1.5.2/lib/rack/handler/webrick.rb:14:in `run'
    /Users/josh/.rvm/gems/ruby-2.1.0@base/gems/rack-1.5.2/lib/rack/server.rb:264:in `start'
    /Users/josh/.rvm/gems/ruby-2.1.0@base/gems/railties-4.0.3/lib/rails/commands/server.rb:84:in `start'
    /Users/josh/.rvm/gems/ruby-2.1.0@base/gems/railties-4.0.3/lib/rails/commands.rb:76:in `block in <top (required)>'
    /Users/josh/.rvm/gems/ruby-2.1.0@base/gems/railties-4.0.3/lib/rails/commands.rb:71:in `tap'
    /Users/josh/.rvm/gems/ruby-2.1.0@base/gems/railties-4.0.3/lib/rails/commands.rb:71:in `<top (required)>'
    bin/rails:8:in `require'
    bin/rails:8:in `<main>'
[2014-03-19 09:38:31] INFO  going to shutdown ...
[2014-03-19 09:38:31] INFO  WEBrick::HTTPServer#start done.

I'm concerned about the "FATAL SignalException: SIGTERM": is this really correct? Webrick is reloaded correctly, but this looks a bit strange to me.

doesn't play well with foreman

I've been using Heroku Cedar and their "foreman" tool doesn't really restart the underlying processes even when rerun sends it a kill signal. Must track this down and see whether it's a foreman or rerun issue.

IOW "rerun foreman" should (and does not) properly emulate "heroku restart"

Ruby threads error

Not that I have rerun working yet anyways, but when I attempt to run:

rerun app.rb

I get the following error:

/Library/Ruby/Gems/1.8/gems/rerun-0.4/lib/osxwatcher.rb:35:in `start': Ruby threads cannot be used in RubyCocoa without patches to the Ruby interpreter

Any ideas?

rerun is slow

On Linux, rerun takes up to a second to notice and relaunch my command after a file change. This is an annoying delay during rapid iteration (which is the whole point of rerun).

Compare the following two commands (run them side by side in two terminals):

rerun --pattern=some_pattern 'date +"%T.%N"'

vs

while true; do date +"%T.%N"; inotifywait -q some_pattern; done

On my system, rerun prints a date roughly a second later than the comparable bash snippet after I save a change to a monitored file.

Monitor .erb files too?

Hey Alex,

I know you said monitoring other files is on it's way but is there an easy way to have it monitor other files as well? Say, .erb files?

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.