Skip to content

Commit

Permalink
add rails server -d section to README
Browse files Browse the repository at this point in the history
closes gh-165
  • Loading branch information
jmettraux committed Sep 11, 2015
1 parent 4f9199d commit a44b722
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Expand Up @@ -1399,6 +1399,7 @@ s = Rufus::Scheduler.singleton
s.every '1m' do

Rails.logger.info "hello, it's #{Time.now}"
Rails.logger.flush
end
```

Expand Down Expand Up @@ -1427,6 +1428,21 @@ The rufus-scheduler singleton is instantiated in the ```config/initializers/sche

*Warning*: this works well with single-process Ruby servers like Webrick and Thin. Using rufus-scheduler with Passenger or Unicorn requires a bit more knowledge and tuning, gently provided by a bit of googling and reading, see [Faq](#faq) above.

### rails server -d

(Written in reply to https://github.com/jmettraux/rufus-scheduler/issues/165 )

There is the handy `rails server -d` that starts a development Rails as a daemon. The annoying thing is that the scheduler as seen above is started in the main process that then gets forked and daemonized. The rufus-scheduler thread (and any other thread) gets lost, no scheduling happens.

I avoid running `-d` in development mode and bother about daemonizing only for production deployment.

These are two well crafted articles on process daemonization, please read them:

* http://www.mikeperham.com/2014/09/22/dont-daemonize-your-daemons/
* http://www.mikeperham.com/2014/07/07/use-runit/

If anyway, you need something like `rails server -d`, why not try `bundle exec unicorn -D` instead? In my (limited) experience, it worked out of the box (well, had to add `gem 'unicorn'` to `Gemfile` first).


## support

Expand Down

0 comments on commit a44b722

Please sign in to comment.