~loggerhead-team/loggerhead/trunk-rich

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
28
29
30
31
#!/usr/bin/env python2.4

import pkg_resources
pkg_resources.require("TurboGears")

import os
import sys

home = os.path.realpath(os.path.dirname(__file__))
pidfile = os.path.join(home, 'loggerhead.pid')

try:
    f = open(pidfile, 'r')
except IOError, e:
    print 'No pid file found.'
    sys.exit(1)

pid = int(f.readline())

try:
    os.kill(pid, 0)
except OSError, e:
    print 'Stale pid file; server is not running.'
    sys.exit(1)

print
print 'Shutting down previous server @ pid %d.' % (pid,)
print

import signal
os.kill(pid, signal.SIGINT)