Ignore:
Timestamp:
07/11/07 16:57:42 (17 years ago)
Author:
bastiaans
Message:

jobarchived/jobarchived.py:

  • added pidfile support

pkg/rpm/init.d/jobarchived,
pkg/rpm/jobmonarch-jobarchived.spec,
Makefile:

  • updated
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/jobarchived/jobarchived.py

    r382 r435  
    3232import getopt, syslog, ConfigParser
    3333
     34def usage():
     35
     36        print
     37        print 'usage: jobarchived [options]'
     38        print 'options:'
     39        print '      --config, -c      configuration file'
     40        print '      --pidfile, -p     pid file'
     41        print '      --help, -h        help'
     42        print
     43
    3444def processArgs( args ):
    3545
    36         SHORT_L = 'c:'
    37         LONG_L  = 'config='
     46        SHORT_L = 'p:hc:'
     47        LONG_L  = [ 'help', 'config=', 'pidfile=' ]
    3848
    3949        config_filename = None
     50
     51        global PIDFILE
     52
     53        PIDFILE = None
    4054
    4155        try:
     
    5367
    5468                        config_filename = value
     69
     70                if opt in [ '--pidfile', '-p' ]:
     71
     72                        PIDFILE         = value
     73
     74                if opt in [ '--help', '-h' ]:
     75
     76                        usage()
     77                        sys.exit( 0 )
    5578
    5679        if not config_filename:
     
    18871910                sys.exit(0)  # end parent
    18881911
     1912        write_pidfile()
     1913
    18891914        # Go to the root directory and set the umask
    18901915        #
     
    19772002        return time.strftime("%a %d %b %Y %H:%M:%S")
    19782003
     2004def write_pidfile():
     2005
     2006        # Write pidfile if PIDFILE exists
     2007        if PIDFILE:
     2008
     2009                pid     = os.getpid()
     2010
     2011                pidfile = open(PIDFILE, 'w')
     2012
     2013                pidfile.write( str( pid ) )
     2014                pidfile.close()
     2015
    19792016# Ooohh, someone started me! Let's go..
    19802017if __name__ == '__main__':
Note: See TracChangeset for help on using the changeset viewer.