-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdev
executable file
·27 lines (25 loc) · 973 Bytes
/
dev
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/env python2.4
import os
# Test if the process is already running
running = False
try:
# Try to read pid file
pid = open('/home/mstram/webapps/railscasts/log/mongrel.pid').read()
# Check if this process is up
lines = os.popen('ps -p %s' % pid).readlines()
if len(lines) > 1:
running = True
else:
# Delete pid file
os.remove('/home/mstram/webapps/railscasts/log/mongrel.pid')
except IOError:
pass
print "Content-type: text/html\r\n"
if running:
print """<html><head><META HTTP-EQUIV="Refresh" CONTENT="2; URL=."></head><body>
Site is starting ...<a href=".">click here<a></body></html>"""
else:
print """<html><head><META HTTP-EQUIV="Refresh" CONTENT="2; URL=."></head><body>
Restarting site ...<a href=".">click here<a></body></html>"""
os.setpgid(os.getpid(), 0)
os.system('/usr/local/bin/mongrel_rails start -d -e development -P /home/mstram/webapps/railscasts/log/mongrel.pid -p 7001')