Skip to content

Commit

Permalink
fixed idempotent crontab
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwoods committed Mar 30, 2012
1 parent e679df3 commit 17ed3aa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions fabfile.py
Expand Up @@ -6,10 +6,11 @@


from fabric.api import *
from fabric.contrib.files import upload_template, exists
from fabric.contrib.files import upload_template, exists, append
import xmlrpclib
import sys

import string, random

try:
from fabsettings import WF_HOST, PROJECT_NAME, REPOSITORY, USER, PASSWORD, VIRTUALENVS, SETTINGS_SUBDIR
Expand Down Expand Up @@ -100,9 +101,16 @@ def install_supervisor():
mode=0750,
)

upload_template('templates/crontab','/tmp/crontab.tmp.1978',{'dir':env.supervisor_dir,},)

run('crontab /tmp/crontab.tmp.1978')

# add to crontab

filename = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(7))
run('crontab -l > /tmp/%s' % filename)
append('/tmp/%s' % filename, '*/10 * * * * %s/start_supervisor.sh start' % env.supervisor_dir)
run('crontab /tmp/%s' % filename)


# create supervisor/conf.d
with cd(env.supervisor_dir):
run('mkdir conf.d')
Expand Down
2 changes: 1 addition & 1 deletion templates/start_supervisor.sh
Expand Up @@ -52,7 +52,7 @@ start () {

stop () {
echo "Stopping Supervisor daemon manager..."
$SUPERVISORCTL shutdown || echo "Failed...!"
$SUPERVISORCTL $OPTS shutdown || echo "Failed...!"
echo "OK"
}

Expand Down

0 comments on commit 17ed3aa

Please sign in to comment.