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
32
33
|
#!/usr/bin/python2.5 -S
#
# Copyright 2009, 2010 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
import _pythonpath
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.SIGTERM)
|