Skip to content
Branch: master
Go to file

Latest commit


Failed to load latest commit information.
Latest commit message
Commit time



  • It starts processes that have a TCP connection of some kind, in foreground mode. Most likely webservices or consumers

  • Runs multiple processes in the same terminal window, colorizing coding the output to to help discern between which output produced which.


  • Add way to detect if a consumer is running by checking for a pid file. Currently checking to see if a port is listening is supported.


Inside of your super project (the one that contains the distributed applications in your universe), config/services.rb, declare your services like this:

ServiceManager.define_service "main-web" do |s|

  # this is the host and port the service will be available on. If something is responding here, don't try to start it again because it's already running       = "localhost"
  s.port       = 8090

  s.start_cmd  = lambda { "script/rails server -p #{port}"}

  # When this regexp is matches, ServiceManager will know that the service is ready
  s.loaded_cue = /WEBrick::HTTPServer#start: pid=\d+ port=\d+/

  # ServiceManager will colorize the output as specified by this terminal color id.
  s.color      = 33

  # The directory
  s.cwd        = Dir.pwd + "/main-web/"

ServiceManager.define_service "tiny-web-service" do |s|

  # ...

Then, add service_manager to your Gemfile:

gem "service_manager"

Starting services

Firing up your services from the command line

If you're going to be running your integration tests multiple times while debugging them or developing new ones, you may not want to wait for your services to start and stop every time you run your integration tests. You may start your services via the start_services command:

bundle exec start_services

Automatically starting as a part of your tests

You should also include the following in your integration test suite, in features/support/env.rb, spec/spec_helper.rb, etc. where applicable :

require "service_manager"

The command will only start services that are not already running, so it will do nothing if you've started your services via the `start_services` command.

If auto-started this way, your services will be automatically shutdown after your integration tests run.


  • Start your services that you use for testing on different ports than you normally start them for development mode, or you will hate life.

Other notes

  • Lingering processes suck. ServiceManager is nice but then aggressive when shutting down processes. First, it sends an INT. If, after 3 seconds, the process hasn't shut down, it sends a KILL signal.

  • For color code references, see the bottom of this doc:


A service manager that helps start and stop services, for example, when testing the interaction between processes in an automated integration test




You can’t perform that action at this time.