Changeset 435


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

jobarchived/jobarchived.py:

  • added pidfile support

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

  • updated
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Makefile

    r431 r435  
    110110rpm-jobarchived:        ${REQUIRED}
    111111        mkdir -p ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/etc/init.d >/dev/null
    112         mkdir -p ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/usr/bin >/dev/null
     112        mkdir -p ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/etc/sysconfig >/dev/null
     113        mkdir -p ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/usr/sbin >/dev/null
    113114        mkdir -p ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/usr/share/jobarchived >/dev/null
    114         install -m 755 jobarchived/jobarchived.py ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/usr/bin
    115         ( cd ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/usr/bin; \
     115        install -m 755 jobarchived/jobarchived.py ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/usr/sbin
     116        ( cd ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/usr/sbin; \
    116117        ln -s jobarchived.py jobarchived || true)
    117118        install jobarchived/jobarchived.conf ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/etc
    118         install pkg/init.d/jobarchived ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/etc/init.d
     119        install pkg/rpm/init.d/jobarchived ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/etc/init.d
     120        install pkg/rpm/sysconfig/jobarchived ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/etc/sysconfig
    119121        install jobarchived/job_dbase.sql \
    120122        ${TMPDIR}/.monarch_buildroot/jobmonarch-jobarchived-${VERSION}-${RELEASE}/usr/share/jobarchived
  • 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__':
  • trunk/pkg/rpm/init.d/jobarchived

    r429 r435  
    1 #! /bin/sh
     1#!/bin/sh
     2#
     3# Init file for the Job Archiving Daemon
     4#
     5# chkconfig: 2345 20 80
     6# description: jobarchived archives information on nodes in RRDS and batch jobs in SQL
     7#
     8# processname: jobarchived
     9# config: /etc/jobarchived.conf
     10# config: /etc/sysconfig/jobarchived
     11# pidfile: /var/run/jobarchived
    212
    3 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    4 DAEMON=/usr/bin/jobarchived
    5 NAME=jobarchived
    6 DESC="Job Archive Daemon"
     13# Source function library.
     14. /etc/rc.d/init.d/functions
    715
    8 export PYTHONPATH=/usr/share/jobarchived:$PYTHONPATH
     16RETVAL=0
     17name=jobarchived
     18prog=/usr/sbin/jobarchived
     19desc="Job Archiving Daemon"
    920
    10 test -x $DAEMON || exit 0
     21if [ -r /etc/sysconfig/$name ]; then
     22        source /etc/sysconfig/$name
     23fi
    1124
    12 set -e
     25start() {
     26        echo -n $"Starting $desc: "
     27        daemon $prog -p /var/run/$name.pid $OPTIONS
     28        RETVAL=$?
     29        echo
     30        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$name
     31        return $RETVAL
     32}
     33
     34stop() {
     35        echo -n $"Stopping $desc: "
     36        killproc $prog
     37        RETVAL=$?
     38        echo
     39        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$name
     40        return $RETVAL
     41}
     42
     43restart() {
     44        stop
     45        start
     46}
    1347
    1448case "$1" in
    15   start)
    16         echo -n "Starting $DESC: "
    17         start-stop-daemon --start --quiet -m --pidfile /var/run/$NAME.pid \
    18                 --exec $DAEMON
    19         sleep 1
    20         ps -ef | grep jobarchived$ | awk '{ print $2 }' >/var/run/$NAME.pid
    21         echo "$NAME."
    22         ;;
    23   stop)
    24         echo -n "Stopping $DESC: "
    25         start-stop-daemon --stop  --quiet --oknodo --name $DAEMON \
    26                 2>&1 > /dev/null
    27         sleep 1
    28         test -f /var/run/$NAME.pid && MYPID=`cat /var/run/$NAME.pid`
    29         test ! -z $MYPID && ps $MYPID 2>&1 > /dev/null && kill -9 $MYPID 2>&1 > /dev/null
    30         echo "$NAME."
    31         ;;
    32   restart|force-reload)
    33         $0 stop
    34         $0 start
    35         ;;
    36   *)
    37         echo "Usage: $N {start|stop|restart}" >&2
    38         exit 1
    39         ;;
     49        start)
     50                start
     51                ;;
     52        stop)
     53                stop
     54                ;;
     55        restart)
     56                restart
     57                ;;
     58        condrestart)
     59                [ -e /var/lock/subsys/$name ] && restart
     60                RETVAL=$?
     61                ;;
     62        status)
     63                status python
     64                RETVAL=$?
     65                ;;
     66        *)
     67                echo $"Usage: $0 {start|stop|restart|condrestart|status}"
     68                RETVAL=1
    4069esac
    4170
    42 exit 0
     71exit $RETVAL
  • trunk/pkg/rpm/jobmonarch-jobarchived.spec

    r390 r435  
    4040
    4141/etc/init.d/jobarchived stop
    42 
    43 
    44 %postun
    45 #!/bin/sh
    46 
    47 PATH=/bin:/sbin:/usr/bin:/usr/sbin
    48 
    4942chkconfig jobarchived off
    5043
     
    5649
    5750%files
    58 "/usr/bin/jobarchived.py"
     51"/usr/sbin/jobarchived.py"
     52"/usr/sbin/jobarchived"
    5953"/etc/init.d/jobarchived"
    60 "/etc/jobarchived.conf"
    61 "/usr/bin/jobarchived"
     54%config "/etc/jobarchived.conf"
     55%config "/etc/sysconfig/jobarchived"
    6256%dir "/usr/share/jobarchived/"
    6357"/usr/share/jobarchived/job_dbase.sql"
Note: See TracChangeset for help on using the changeset viewer.