Pages

Sunday 2 February 2014

Runit: process monitoring made easy

Install: apt-get install -y runit # Setup the application's runit directory /etc/sv/application: file.directory: - mode: 0755 - user: someuser - group: someuser - recurse: - user - group - mode
# Create the application's runit run script /etc/sv/application/run: file.managed: - name: /etc/sv/application/run - template: jinja - user: someuser - group: someuser - source: salt://unicorn/templates/sv-unicorn-run.jinja - context: unicorn_command: unicorn_rails unicorn_environment: vagrant # Create the application's runit log run script /etc/sv/application/log/run: file.managed: - name: /etc/sv/application/log/run - user: someuser - group: someuser - source: salt://runit/templates/sv-log-run # Create the log directory /etc/sv/application/log/main: file.directory: - user: someuser - group: someuser - makedirs: True # Create the supervise directory /etc/sv/application/supervise:
file.directory: - mode: 0755
- user: someuser - group: someuser - makedirs: True - recurse: - user - group - mode # Link the /etc/service/application to kickoff # runit to start managing the application /etc/service/application: file.symlink: - target: /etc/sv/application

Reading recent error messages through ps

runsvdir has a useful feature called ‘ps logging’. If any process under its control 
writes anything to its stderr, it appears on runsvdir’s ps entry. So, to have a quick 
glance at what’s currently going on in the stack,
run a command like this: ps -ef | grep runsvdir, and you may see something like this:
 [root@vmtest haproxy]# ps -ef | grep runsvdir
    root      3153     1  0 02:09 ?        00:00:01 runsvdir -P /var/service 
log: aproxy' process is not running?'haproxy' trying to restart?monit: pidfile
 `/var/service/haproxy/supervise/pid' does not contain a valid pidn  umber?monit: 
pidfile `/var/service/haproxy/supervise/pid' does not contain a valid pidnumber?
'haproxy' start:/usr/bin/sv?monit: pidfile `/var/service/haproxy/supervise/pid' 
does not contain a valid pidnumber?'haproxy' process is running with pid 4081?...

Reference:

  1. http://smarden.org/runit/index.html
  2. http://www.sanityinc.com/articles/init-scripts-considered-harmful/
  3. http://rubyworks.rubyforge.org/manual/runit.html

No comments:

Post a Comment