Charlie Andrews
Charlie Andrews

Reputation: 1467

fabric restarting my supervisord service kills the service

I have a tornado web application running using supervisord. I manually start, stop and restart the Supervisord service from ssh and it works fine. I am using fabric from my local machine to do the following:

  1. Run unit tests
  2. commit/push to my git server
  3. pull changes from development server
  4. restart the Supervisord service to update the application

I get no errors when running the fabfile, but my server is down after I run it. The following is my fabfile code:

from fabric.api import *
from fabric.context_managers import settings

def prepare_deploy():
    local('py.test')
    local('git add .')
    x = raw_input('what would you like your commit message to be?   ')
    local('git diff --quiet --exit-code --cached || git commit -m "' + x + '"')
    local('git push origin master')

def dev():
    prepare_deploy()
    x = raw_input('Please enter the location of your keyFile for the dev server ')
    if x == '':
        key = 'key_file'
    else:
        key = x
    with settings(
            host_string='dev_server_name',
            user='user_name',
            Key_filename=key,
            use_ssh_config = True):
        code_dir='~/path/to/code/'
        with cd(code_dir):
            run("git pull origin master")
            run("sudo python setup.py install")
            run("sudo service supervisord restart")

After this is done, my web application is down. Any ideas on why this is happening?

Upvotes: 3

Views: 2099

Answers (2)

Thomas Fenzl
Thomas Fenzl

Reputation: 4392

Supervisor is a tool to manage services, there is no need to restart it just to restart something under its control.

It comes with a command line tool to manage processes, supervisorctl. You can use it as a CLI interface or an interactive shell.

If you want to restart a service supervisorctl restart <service name> (with appropriate rights, so probably using sudo does that. If you changed the service's configuration, use supervisorctl update to restart affected processes. This way you get to use the logfile from supervisor in case your process doesn't start.

Upvotes: 4

twil
twil

Reputation: 6162

Supervisor has bug in init.d script. Don't do restart. Do stop and then start.

Upvotes: 0

Related Questions