~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to stop-loggerhead

  • Committer: Matt Nordhoff
  • Date: 2009-06-03 23:21:52 UTC
  • mfrom: (359.2.2 allow-writes)
  • Revision ID: mnordhoff@mattnordhoff.com-20090603232152-9dqje90otjz7s82m
Support writing to the Bazaar server.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python2.4
 
1
#!/usr/bin/env python
 
2
# This program is free software; you can redistribute it and/or modify
 
3
# it under the terms of the GNU General Public License as published by
 
4
# the Free Software Foundation; either version 2 of the License, or
 
5
# (at your option) any later version.
 
6
#
 
7
# This program is distributed in the hope that it will be useful,
 
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
# GNU General Public License for more details.
 
11
#
 
12
# You should have received a copy of the GNU General Public License
 
13
# along with this program; if not, write to the Free Software
 
14
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
2
15
 
3
 
import pkg_resources
4
 
pkg_resources.require("TurboGears")
 
16
"""A script for stopping the loggerhead process."""
5
17
 
6
18
import os
7
19
import sys
 
20
from optparse import OptionParser
8
21
 
9
22
home = os.path.realpath(os.path.dirname(__file__))
10
 
pidfile = os.path.join(home, 'loggerhead.pid')
 
23
default_pidfile = os.path.join(home, 'loggerhead.pid')
 
24
parser = OptionParser(usage='usage: %prog [options]', version='%prog')
 
25
parser.add_option('-p', '--pidfile', dest="pidfile", default=default_pidfile,
 
26
                  help="override pidfile location")
 
27
 
 
28
options, args = parser.parse_args()
 
29
if len(args) > 0:
 
30
    parser.error('No filename arguments are used, only options.')
11
31
 
12
32
try:
13
 
    f = open(pidfile, 'r')
 
33
    f = open(options.pidfile, 'r')
14
34
except IOError, e:
15
 
    print 'No pid file found.'
 
35
    print 'Pid file %s not found.' % options.pidfile
16
36
    sys.exit(1)
17
37
 
18
38
pid = int(f.readline())
24
44
    sys.exit(1)
25
45
 
26
46
print
27
 
print 'Shutting down previous server @ pid %d.' % (pid,)
 
47
print 'Shutting down previous server @ pid %d.' % pid
28
48
print
29
49
 
30
50
import signal