Starting additional services (resque, redis) using the "rails server" command

I would like my Rails development environment to automatically start redis and resque (and possibly in other projects, mongod, mysql-server, etc.) for me, in the following cases:

  • When starting the development server rails server.

In addition, it would be nice if, in the following cases, services that were already running were detected, and if they did not start, too:

  • Rake rspec, rspec / spec when running tests.
  • At startup rails console.

When shutting down, rails serverrunning child services must also be disabled.

What is the right place for such additional startup scripts?

And how to avoid starting them in production, too (where I run everything through the services / etc / init.d)?

+3
source share
2 answers

Many of these built-in tasks are already available as rake tasks.

You can create a master rake task that does all this.

For example, with resque you get "rake resque: start", "rake resque: scheduler: start", etc.

You can create a common โ€œstartingโ€ task, which depends on the rest. In the same way, the โ€œstopโ€ task will cover everything.

So you would do:

rake start # starts all associated processes
rake stop  # stops them all

It is also very useful to use from Capistrano when you end up deploying your code somewhere else. Graphic tasks are very easy to call from Capistrano.

+2
source

, - script. rails , .

, nez . , rails .

, , env. . script .

script script. . , , .

+1

Source: https://habr.com/ru/post/1795710/


All Articles