IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 3, 2010, 8:50:52 AM (16 years ago)
Author:
eugene
Message:

updates from trunk

Location:
branches/simtest_nebulous_branches
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/simtest_nebulous_branches

  • branches/simtest_nebulous_branches/ippTasks/pstamp.pro

    r25059 r27840  
    1 
    2 #$VERBOSE = 3
     1# pstamp.pro : Postage Stamp Server tasks
     2
     3check.globals
     4
     5$LOGSUBDIR = $LOGDIR/pstamp
     6mkdir $LOGSUBDIR
    37
    48# these variables wil cycle through the known database names
     
    812$pstampJob_DB = 0
    913$pstampFin_DB = 0
     14$pstampRev_DB = 0
     15$pstampDep_DB = 0
    1016
    1117# set PS_DBSERVER if postage stamp database host is not the same as the value for DBSERVER in site.config
    12 # warning: no quotes around the two words. it cause it to get passed to pstamptool as one word
    13 # tricky to debug problem ensues
     18# warning: no quotes around the two words. That causes the variable to get passed to pstamptool as one word
     19# and a tricky to debug problem ensues
    1420# example:
    15 # $PSDBSERVER = -dbserver hostname
    16 if ($?PSDBSERVER == 0)
     21# $PS_DBSERVER = -dbserver hostname
     22
     23if ($?PS_DBSERVER == 0)
    1724    $PS_DBSERVER = ""
    1825end
     
    2229    book init pstampJob
    2330    book init pstampFinish
     31    book init pstampDependent
    2432end
    2533
    2634pstamp.reset
    27 
    2835
    2936macro pstamp.on
     
    5158        active true
    5259    end
    53 end
     60    task pstamp.job.revert
     61        active true
     62    end
     63    task pstamp.dependent.load
     64        active true
     65    end
     66end
     67
    5468
    5569macro pstamp.off
     
    7690        active false
    7791    end
     92    task pstamp.job.revert
     93        active false
     94    end
     95    task pstamp.dependent.load
     96        active true
     97    end
     98end
     99
     100macro pstamp.revert.on
     101    task pstamp.job.revert
     102        active true
     103    end
     104end
     105macro pstamp.revert.off
     106    task pstamp.job.revert
     107        active false
     108    end
    78109end
    79110
     
    83114    periods     -poll $LOADPOLL
    84115    periods     -exec 10
    85     periods     -timeout 30
     116    periods     -timeout 120
    86117    npending    1
    87118
    88119    task.exec
     120        stdout NULL
     121        stderr $LOGSUBDIR/pstamp.request.find.log
    89122        if ($DB:n == 0)
    90123            option DEFAULT
     
    124157
    125158    task.exec
     159        stdout $LOGSUBDIR/pstamp.request.load.log
     160        stderr $LOGSUBDIR/pstamp.request.load.log
    126161        $run = pstamptool -pendingreq
    127162        if ($DB:n == 0)
     
    134169        end
    135170        add_poll_args run
     171        add_poll_labels run
    136172        command $run
    137173    end
     
    166202
    167203    task.exec
     204        stdout $LOGSUBDIR/pstamp.request.run.log
     205        stderr $LOGSUBDIR/pstamp.request.run.log
    168206        book npages pstampRequest -var N
    169207        if ($N == 0) break
     
    177215        book getword pstampRequest $pageName uri -var URI
    178216        book getword pstampRequest $pageName ds_outProduct -var PRODUCT
     217        book getword pstampRequest $pageName label -var LABEL
    179218
    180219        host anyhost
    181220
    182         $run = pstamp_parser_run.pl --req_id $REQ_ID --uri $URI --product $PRODUCT --redirect-output
     221        $run = pstamp_parser_run.pl --req_id $REQ_ID --uri $URI --product $PRODUCT --label $LABEL --redirect-output
    183222
    184223        add_standard_args run
     
    221260
    222261    task.exec
     262        stdout $LOGSUBDIR/pstamp.finish.load.log
     263        stderr $LOGSUBDIR/pstamp.finish.load.log
     264        $run = pstamptool  -completedreq
    223265        if ($DB:n == 0)
    224266            option DEFAULT
    225             command pstamptool  -completedreq
    226267        else
    227268            option $DB:$pstampFin_DB
    228             command pstamptool  -completedreq -dbname $DB:$pstampFin_DB $PS_DBSERVER
     269            $run = $run -dbname $DB:$pstampFin_DB $PS_DBSERVER
    229270            $pstampFin_DB ++
    230271            if ($pstampFin_DB >= $DB:n) set pstampFin_DB = 0
    231272        end
     273        add_poll_args run
     274        add_poll_labels run
     275        command $run
    232276    end
    233277
     
    257301    periods     -poll $RUNPOLL
    258302    periods     -exec $RUNEXEC
    259     periods     -timeout 300
    260 
    261     task.exec
     303    periods     -timeout 2400
     304    host        anyhost
     305
     306    task.exec
     307        stdout $LOGSUBDIR/request.finish.run.log
     308        stderr $LOGSUBDIR/request.finish.run.log
    262309        book npages pstampFinish -var N
    263310        if ($N == 0) break
     
    315362
    316363    task.exec
     364        stdout $LOGSUBDIR/pstamp.job.load.log
     365        stderr $LOGSUBDIR/pstamp.job.load.log
     366        $run = pstamptool -pendingjob
    317367        if ($DB:n == 0)
    318368            option DEFAULT
    319             command pstamptool -pendingjob -limit 10
    320369        else
    321370            option $DB:$pstampJob_DB
    322             command pstamptool -pendingjob -limit 10 -dbname $DB:$pstampJob_DB $PS_DBSERVER
     371            $run = $run -dbname $DB:$pstampJob_DB $PS_DBSERVER
    323372            $pstampJob_DB ++
    324373            if ($pstampJob_DB >= $DB:n) set pstampJob_DB = 0
    325374        end
     375        add_poll_args run
     376        add_poll_labels run
     377        command $run
    326378    end
    327379
     
    338390    end
    339391
     392    task.exit   crash
     393        showcommand crash
     394    end
     395
     396    task.exit   timeout
     397        showcommand timeout
     398    end
     399
    340400    task.exit   default
    341401        showcommand failure
    342402    end
    343403
    344     task.exit   crash
    345         showcommand crash
    346     end
    347 
    348     task.exit   timeout
    349         showcommand timeout
    350     end
    351404end
    352405
     
    357410
    358411    task.exec
     412        stdout $LOGSUBDIR/pstamp.job.run.log
     413        stderr $LOGSUBDIR/pstamp.job.run.log
    359414        book npages pstampJob -var N
    360         if ($N == 0) break
     415        if ($N == 0)
     416            periods -exec $RUNEXEC
     417            break
     418        end
     419        periods -exec 0.05
    361420       
    362421        book getpage pstampJob 0 -var pageName -key pantaskState INIT
     
    371430        book getword pstampJob $pageName dbname -var DBNAME
    372431        book getword pstampJob $pageName outputBase -var OUTPUT_BASE
     432        book getword pstampJob $pageName options -var OPTIONS
    373433
    374434        if ($VERBOSE > 1)
     
    378438        host anyhost
    379439
    380         $run = pstamp_job_run.pl --job_id $JOB_ID --job_type $JOB_TYPE --rownum $ROWNUM --output_base $OUTPUT_BASE --redirect-output
     440        $run = pstamp_job_run.pl --job_id $JOB_ID --job_type $JOB_TYPE --rownum $ROWNUM --output_base $OUTPUT_BASE --options $OPTIONS --redirect-output
    381441        add_standard_args run
    382442
     
    418478    end
    419479end
     480
     481task pstamp.job.revert
     482    host        local
     483
     484    periods     -poll $LOADPOLL
     485    periods     -exec 300
     486    periods     -timeout 300
     487    npending    1
     488
     489    task.exec
     490        stdout $LOGSUBDIR/pstamp.job.revert.log
     491        stderr $LOGSUBDIR/pstamp.job.revert.log
     492        $run = pstamptool -revertjob -all
     493        if ($DB:n == 0)
     494            option DEFAULT
     495        else
     496            $run = $run $PS_DBSERVER -dbname $DB:$pstampRev_DB
     497            $pstampRev_DB ++
     498            if ($pstampRev_DB >= $DB:n) set pstampRev_DB = 0
     499        end
     500        add_poll_args run
     501        add_poll_labels run
     502        command $run
     503    end
     504
     505    task.exit $EXIT_SUCCESS
     506        # nothing to do
     507    end
     508
     509    task.exit   default
     510        showcommand failure
     511    end
     512
     513    task.exit   crash
     514        showcommand crash
     515    end
     516
     517    task.exit   timeout
     518        showcommand timeout
     519    end
     520end
     521
     522task pstamp.dependent.load
     523    host        local
     524
     525    periods     -poll $LOADPOLL
     526    # XXX: create a macro for this time
     527    periods     -exec 10
     528#    periods     -exec $LOADEXEC
     529    periods     -timeout 300
     530    npending    1
     531
     532    task.exec
     533        stdout $LOGSUBDIR/pstamp.dependent.load.log
     534        stderr $LOGSUBDIR/pstamp.dependent.load.log
     535        $run = pstamptool -pendingdependent
     536        if ($DB:n == 0)
     537            option DEFAULT
     538        else
     539            option $DB:$pstampDep_DB
     540            $run = $run -dbname $DB:$pstampDep_DB $PS_DBSERVER
     541            $pstampDep_DB ++
     542            if ($pstampDep_DB >= $DB:n) set pstampDep_DB = 0
     543        end
     544        add_poll_args run
     545        add_poll_labels run
     546        command $run
     547    end
     548
     549    task.exit $EXIT_SUCCESS
     550        ipptool2book stdout pstampDependent -key dep_id -uniq -setword dbname $options:0 -setword pantaskState INIT
     551
     552        book npages pstampDependent -var N
     553        if ($VERBOSE > 2)
     554            book listbook pstampDependent
     555        end
     556
     557        # delete existing entries in the appropriate pantaskStates
     558        process_cleanup pstampDependent
     559    end
     560
     561    task.exit   crash
     562        showcommand crash
     563    end
     564
     565    task.exit   timeout
     566        showcommand timeout
     567    end
     568
     569    task.exit   default
     570        showcommand failure
     571    end
     572
     573end
     574
     575task pstamp.dependent.run
     576    periods     -poll $RUNPOLL
     577    periods     -exec $RUNEXEC
     578    periods     -timeout 300
     579
     580    task.exec
     581#        stdout $LOGSUBDIR/pstamp.dependent.run.log
     582#        stderr $LOGSUBDIR/pstamp.dependent.run.log
     583        book npages pstampDependent -var N
     584        if ($N == 0)
     585            periods -exec $RUNEXEC
     586            break
     587        end
     588        periods -exec 0.05
     589       
     590        book getpage pstampDependent 0 -var pageName -key pantaskState INIT
     591        if ("$pageName" == "NULL") break
     592
     593        #echo pageName: $pageName
     594
     595        book setword pstampDependent $pageName pantaskState RUN
     596        book getword pstampDependent $pageName dep_id     -var DEP_ID
     597        book getword pstampDependent $pageName state      -var STATE
     598        book getword pstampDependent $pageName stage      -var STAGE
     599        book getword pstampDependent $pageName stage_id   -var STAGE_ID
     600        book getword pstampDependent $pageName component  -var COMPONENT
     601        book getword pstampDependent $pageName imagedb    -var IMAGEDB
     602        book getword pstampDependent $pageName rlabel     -var RLABEL
     603#        book getword pstampDependent $pageName output_base -var OUTPUT_BASE
     604        book getword pstampDependent $pageName need_magic -var NEED_MAGIC
     605        book getword pstampDependent $pageName dbname     -var DBNAME
     606
     607        if ($VERBOSE > 1)
     608            book listpage pstampDependent $pageName
     609        end
     610
     611        host anyhost
     612
     613        if ("$NEED_MAGIC" == "T")
     614            $NEED_MAGIC="--need_magic"
     615        else
     616            $NEED_MAGIC=""
     617        end
     618
     619        # XXX: use OUTPUT_BASE for this
     620        $LOGFILE = /data/ipp053.0/home/bills/pstamp/logs/pstampdep.$DEP_ID.log
     621#        echo logfile is $LOGFILE
     622#        stdout $LOGFILE
     623#        stderr $LOGFILE
     624
     625        $run = pstamp_checkdependent.pl --dep_id $DEP_ID --stage_id $STAGE_ID --stage $STAGE --component $COMPONENT --imagedb $IMAGEDB --rlabel $RLABEL $NEED_MAGIC
     626        add_standard_args run
     627
     628        options $pageName
     629
     630        if ($VERBOSE > 1)
     631            echo command $run
     632        end
     633        command $run
     634    end
     635
     636
     637    task.exit $EXIT_SUCCESS
     638        if ($VERBOSE > 1)
     639            echo pstamp.dependent.run task.exit $DEP_ID status: $JOB_STATUS
     640        end
     641        process_exit pstampDependent $options:0 $JOB_STATUS
     642    end
     643    task.exit default
     644        if ($VERBOSE > 1)
     645            echo pstamp.job.run task.exit $DEP_ID status: $JOB_STATUS
     646        end
     647        showcommand failure
     648        process_exit pstampDependent $options:0 $JOB_STATUS
     649    end
     650
     651    task.exit crash
     652        echo pstamp.job.run task.crash $DEP_ID status: $JOB_STATUS
     653        process_exit pstampDependent $options:0 $JOB_STATUS
     654        showcommand crash
     655        book setword pstampDependent $options:0 pantaskState CRASH
     656    end
     657
     658    task.exit timeout
     659        echo pstamp.job.run task.timeout $DEP_ID status: $JOB_STATUS
     660        process_exit pstampDependent $options:0 $JOB_STATUS
     661        showcommand timeout
     662        book setword pstampDependent $options:0 pantaskState TIMEOUT
     663    end
     664end
     665
Note: See TracChangeset for help on using the changeset viewer.