~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to stop-loggerhead

  • Committer: Jelmer Vernooij
  • Date: 2008-08-06 18:39:15 UTC
  • mto: (197.1.9 pathargs)
  • mto: This revision was merged to the branch mainline in revision 202.
  • Revision ID: jelmer@samba.org-20080806183915-81q0zlnxq57s0egb
Add --pidfile option to stop-loggerhead.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
"""A script for stopping the loggerhead process."""
17
17
 
18
 
import pkg_resources
19
 
pkg_resources.require("TurboGears")
20
 
 
21
18
import os
22
19
import sys
 
20
from optparse import OptionParser
 
21
 
 
22
from loggerhead import release
23
23
 
24
24
home = os.path.realpath(os.path.dirname(__file__))
25
 
pidfile = os.path.join(home, 'loggerhead.pid')
 
25
default_pidfile = os.path.join(home, 'loggerhead.pid')
 
26
parser = OptionParser(usage='usage: %prog [options]', version='%prog ' + release.version)
 
27
parser.add_option('-p', '--pidfile', dest="pidfile", default=default_pidfile,
 
28
                                  help="override pidfile location")
 
29
 
 
30
options, args = parser.parse_args()
 
31
if len(args) > 0:
 
32
        parser.error('No filename arguments are used, only options.')
26
33
 
27
34
try:
28
 
    f = open(pidfile, 'r')
 
35
    f = open(options.pidfile, 'r')
29
36
except IOError, e:
30
 
    print 'No pid file found.'
 
37
    print 'Pid file %s not found.' % options.pidfile
31
38
    sys.exit(1)
32
39
 
33
40
pid = int(f.readline())