alexch / rerun

Restarts an app when the filesystem changes. Uses growl and FSEventStream if on OS X.
Other
984 stars 80 forks source link

Running two commands (bundle && rails s) #111

Closed jmuheim closed 6 years ago

jmuheim commented 7 years ago

I have the following rerun command:

rerun --pattern '{Gemfile.lock,bin/server,config/application.rb...}' --no-notify --signal INT --background --clear -- rails s -b 0.0.0.0

Sometimes rerun is triggered because the Gemfile changes; and then sometimes it's because a new gem was added which isn't installed yet.

For this, I'd like not to only run rails s but bundle && rails s.

rerun --pattern '{Gemfile.lock,bin/server,config/application.rb...}' --no-notify --signal INT --background --clear -- bundle && rails s -b 0.0.0.0

Sadly, this doesn't work for me:

...
Using compass-rails 3.0.2
Using rails_admin 1.1.1
Bundle complete! 82 Gemfile dependencies, 191 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.

13:27:49 [rerun] Src Launch Failed
13:27:49 [rerun] Watching . for {Gemfile.lock,bin/server,config/application.rb,config/environment.rb,config/environments/development.rb,config/initializers/*.rb,lib/**/*.rb,config/database.yml,config/boot.rb}

Then nothing happens anymore.

Interestingly, when I hit Ctrl+C, it proceeds like this:

^C
13:28:11 [rerun] Src stopping
13:28:11 [rerun] Sending signal INT to 61796
=> Booting Puma
=> Rails 5.0.1 application starting in development on http://0.0.0.0:3001
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.6.2 (ruby 2.2.6-p396), codename: Sleepy Sunday Serenity
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3001
Use Ctrl-C to stop

So maybe there's another way to execute two commands in a row?

elbuki commented 7 years ago

My solution is creating a shell script, then add all the commands that you want to be run in there and invoke it into the rerun command, like this.

rerun --background --pattern="**/*.{rb}" --dir bin,src "./bin/reload"'
jmuheim commented 7 years ago

That's a very cool suggestion. Thanks!

alexch commented 6 years ago

More detail: && is a shell operator, but rerun works below the shell, directly on processes, so it can't do command pipes like that.