I'm using webfaction, and the following script works for me:
import time
import os
BASE_DIR = "/path/to/your/app/"
def stopit(app):
os.popen( os.path.join(BASE_DIR, "apache2", "bin", "stop") )
def startit(app):
os.popen( os.path.join(BASE_DIR, "apache2", "bin", "start") )
def restart(app):
stopit(app)
time.sleep(1)
startit(app)
The "stop" script then looks like this:
#!/usr/local/bin/python
import os
lines = os.popen('ps -u username -o pid,command').readlines()
running = False
for line in lines:
if '/path/to/app/apache2/conf/httpd.conf' in line:
running = True
proc_id = line.split()[0]
os.system('kill %s 2> /dev/null' % proc_id)
if not running:
print "Not running"
else:
print "Stopped"
The "start" script:
/path/to/app/apache2/bin/httpd -f /path/to/app/apache2/conf/httpd.conf
Ryan Ginstrom
2010-09-15 10:21:35