Proctor

Proctor is a configurable process manager that supports:

  • customized upstart/init scripts
  • separate start/stop/restart commands
  • multiple managent tools like monit & upstart
  • lightweight process monitoring
  • config file cleanup

Proctor was inspired by the excellent Foreman gem. Proctor seeks to retain the clean and simple design of Foreman, while adding a bit more configurability.

Installation

Add this line to your application's Gemfile:

gem 'proctor'

And then execute:

$ bundle

Or install it yourself as:

$ gem install proctor

Usage

Start by running 'proctor help'.

Proctor is useful when an application requires a suite of independent processes which need to be managed and monitored.

For development, Proctor brings up all your processes in a single screen, just like Foreman.

For production, Proctor is designed to work in concert with config tools like Puppet/Chef, and with deploy tools like Capistrano. Proctor can create tailored application manifests for single or multi-server deployments.

Background

With Proctor, all of your application processes are described in a single YAML file, called a Proctorfile.

In the Proctorfile, you can designate one or more Nodes. Example Nodes include web, db, backup. Each node has a list of Services.

nodes:
  web:
    - passenger
    - faye
    - jobq
    - renderpro
    - redis
  db:
    - postgres-shared
  backup:
    - postgres

Services are defined independently. Example Services include unicorn, faye, postgres and redis.

services:
  unicorn:
    start_command: "bin/unicorn --log_file shared/log/<%= name %>.log"
    stop_command:  "qwer"
  passenger:
    start_command: "bin/passenger --log_file shared/log/<%= name %>.log"
    stop_command:  "qwer"
  faye:
    start_command: "qwer"
    export.monit.memory_limit:  "<%= ForemanEnv.production? ? '20MB' : '10MB' %>"
    exports_to:            ['monit', 'upstart']
    start_command: "script/faye_script.sh"
    port: 2343

Services are controlled and monitored by Managers. Example Managers include upstart, monit, and foreman.

managers:
  upstart:
    export_directory: "/etc/init"
    start_command:    "/sbin/init start <%= app_name %>"
    stop_command:     "/sbin/init stop <%= app_name %>"
    status_command:   "/sbin/init status <%= app_name %>"
  monit:
    export_directory: "/etc/monit/conf.d"
    reload_command:   "monit reload"
    stop_command:     "monit quit"
    start_command:    "monit"
    status_command:   "monit summary"
    pidfile:          "/a/b/c"
  foreman:
    start_command:    "foreman start"
    use_master_template: true
    use_worker_template: false

In a Proctor run, ERB templates are used to create config files that are exported to managers. Different Templates can be established for each type of Service and Manager.

# Monit config file (template: <%= original_template_file %>)
# Generated by Proctor at <%=  Time.now %>
#   Hostname: <%= ENV['host'] %>
#   Target Directory: <%= export_directory %>

check process <%= role_name %> with pidfile <%= pidfile %>
  start program = "<%= start_command %>"
  stop program = "<%= stop_command %>"

In a Proctor run, multiple Proctorfiles can be referenced, and their values will be merged together.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request