0.02
No commit activity in last 3 years
No release in over 3 years
It launches and interacts with a set of services from a single terminal window. * Colorizes output for each process to help distinguish them. * Useful for integration-test applications where you need to start up several processes and test them all. * Built because servolux wasn't working very well for me. * Can detect exactly when a service is successfully launched by watching the output of the process.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

ServiceManager¶ ↑

  • 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.

TODO:

  • 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.

Usage¶ ↑

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
  s.host       = "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/"
end

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

  # ...
end

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"
ServiceManager.start

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.

Tips¶ ↑

  • 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: www.termsys.demon.co.uk/vtansi.htm