IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

updates from trunk

Location:
branches/simmosaic_branches
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/simmosaic_branches

  • branches/simmosaic_branches/ippTasks/pstamp.pro

    r24831 r27839  
    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 $PS_DBSERVER = ""
     21# $PS_DBSERVER = -dbserver hostname
     22
     23if ($?PS_DBSERVER == 0)
     24    $PS_DBSERVER = ""
     25end
    1726
    1827macro pstamp.reset
     
    2029    book init pstampJob
    2130    book init pstampFinish
     31    book init pstampDependent
    2232end
    2333
    2434pstamp.reset
    25 
    2635
    2736macro pstamp.on
     
    4958        active true
    5059    end
    51 end
     60    task pstamp.job.revert
     61        active true
     62    end
     63    task pstamp.dependent.load
     64        active true
     65    end
     66end
     67
    5268
    5369macro pstamp.off
     
    7490        active false
    7591    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
    76109end
    77110
     
    81114    periods     -poll $LOADPOLL
    82115    periods     -exec 10
    83     periods     -timeout 30
     116    periods     -timeout 120
    84117    npending    1
    85118
    86119    task.exec
     120        stdout NULL
     121        stderr $LOGSUBDIR/pstamp.request.find.log
    87122        if ($DB:n == 0)
    88123            option DEFAULT
     
    122157
    123158    task.exec
     159        stdout $LOGSUBDIR/pstamp.request.load.log
     160        stderr $LOGSUBDIR/pstamp.request.load.log
    124161        $run = pstamptool -pendingreq
    125162        if ($DB:n == 0)
     
    132169        end
    133170        add_poll_args run
     171        add_poll_labels run
    134172        command $run
    135173    end
     
    164202
    165203    task.exec
     204        stdout $LOGSUBDIR/pstamp.request.run.log
     205        stderr $LOGSUBDIR/pstamp.request.run.log
    166206        book npages pstampRequest -var N
    167207        if ($N == 0) break
     
    175215        book getword pstampRequest $pageName uri -var URI
    176216        book getword pstampRequest $pageName ds_outProduct -var PRODUCT
    177 
    178         $run = pstamp_parser_run.pl --req_id $REQ_ID --uri $URI --product $PRODUCT --redirect-output
     217        book getword pstampRequest $pageName label -var LABEL
     218
     219        host anyhost
     220
     221        $run = pstamp_parser_run.pl --req_id $REQ_ID --uri $URI --product $PRODUCT --label $LABEL --redirect-output
    179222
    180223        add_standard_args run
     
    217260
    218261    task.exec
     262        stdout $LOGSUBDIR/pstamp.finish.load.log
     263        stderr $LOGSUBDIR/pstamp.finish.load.log
     264        $run = pstamptool  -completedreq
    219265        if ($DB:n == 0)
    220266            option DEFAULT
    221             command pstamptool  -completedreq
    222267        else
    223268            option $DB:$pstampFin_DB
    224             command pstamptool  -completedreq -dbname $DB:$pstampFin_DB $PS_DBSERVER
     269            $run = $run -dbname $DB:$pstampFin_DB $PS_DBSERVER
    225270            $pstampFin_DB ++
    226271            if ($pstampFin_DB >= $DB:n) set pstampFin_DB = 0
    227272        end
     273        add_poll_args run
     274        add_poll_labels run
     275        command $run
    228276    end
    229277
     
    253301    periods     -poll $RUNPOLL
    254302    periods     -exec $RUNEXEC
    255     periods     -timeout 300
    256 
    257     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
    258309        book npages pstampFinish -var N
    259310        if ($N == 0) break
     
    311362
    312363    task.exec
     364        stdout $LOGSUBDIR/pstamp.job.load.log
     365        stderr $LOGSUBDIR/pstamp.job.load.log
     366        $run = pstamptool -pendingjob
    313367        if ($DB:n == 0)
    314368            option DEFAULT
    315             command pstamptool -pendingjob -limit 10
    316369        else
    317370            option $DB:$pstampJob_DB
    318             command pstamptool -pendingjob -limit 10 -dbname $DB:$pstampJob_DB $PS_DBSERVER
     371            $run = $run -dbname $DB:$pstampJob_DB $PS_DBSERVER
    319372            $pstampJob_DB ++
    320373            if ($pstampJob_DB >= $DB:n) set pstampJob_DB = 0
    321374        end
     375        add_poll_args run
     376        add_poll_labels run
     377        command $run
    322378    end
    323379
     
    334390    end
    335391
     392    task.exit   crash
     393        showcommand crash
     394    end
     395
     396    task.exit   timeout
     397        showcommand timeout
     398    end
     399
    336400    task.exit   default
    337401        showcommand failure
    338402    end
    339403
    340     task.exit   crash
    341         showcommand crash
    342     end
    343 
    344     task.exit   timeout
    345         showcommand timeout
    346     end
    347404end
    348405
     
    353410
    354411    task.exec
     412        stdout $LOGSUBDIR/pstamp.job.run.log
     413        stderr $LOGSUBDIR/pstamp.job.run.log
    355414        book npages pstampJob -var N
    356         if ($N == 0) break
     415        if ($N == 0)
     416            periods -exec $RUNEXEC
     417            break
     418        end
     419        periods -exec 0.05
    357420       
    358421        book getpage pstampJob 0 -var pageName -key pantaskState INIT
     
    363426        book setword pstampJob $pageName pantaskState RUN
    364427        book getword pstampJob $pageName job_id -var JOB_ID
     428        book getword pstampJob $pageName jobType -var JOB_TYPE
     429        book getword pstampJob $pageName rownum -var ROWNUM
    365430        book getword pstampJob $pageName dbname -var DBNAME
    366431        book getword pstampJob $pageName outputBase -var OUTPUT_BASE
     432        book getword pstampJob $pageName options -var OPTIONS
    367433
    368434        if ($VERBOSE > 1)
     
    370436        end
    371437
    372 
    373         $run = pstamp_job_run.pl --job_id $JOB_ID --redirect-output --output_base $OUTPUT_BASE
     438        host anyhost
     439
     440        $run = pstamp_job_run.pl --job_id $JOB_ID --job_type $JOB_TYPE --rownum $ROWNUM --output_base $OUTPUT_BASE --options $OPTIONS --redirect-output
    374441        add_standard_args run
    375442
     
    411478    end
    412479end
     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.