#!/bin/ksh #****** shellscript/gw_start_seq_tasks.sh # name # gw_start_seq_tasks.sh # synopsis # ./gw_start_seq_tasks.sh # function # start process sequence from defined execution order list # author # bs # creation date # 01.10.2006 # history # 01.10.2006 - bs - initial implementation # 24.04.2007 - bs - review because of hardcoded paths and credentials # 29.04.2007 - bs - added location and /nolog option by sqlplus connections # 04.05.2007 - bs - checked status of first start of wf. # 05.05.2007 - bs - renamed log files, to contain prcprocessid # inputs # param1 - parameter file defined by absolute path # output # 0 - success / 1 - error # notes # there is only one input parameter : parameter file with absolute path # all server and database parameters are taken from infa.txt file # dynamic parameter file name and task list file name are taken from the parameter file # source #
param_file=${1} file_name=`basename $param_file` # as a working directory is used the same directory where is parameterfile dir=`echo ${param_file} | sed 's/'$file_name'//g'` inf_file=${dir}/infa.txt pc_server=`grep -m1 '$$pcserver' $inf_file | cut -f2 -d '='` port=`grep -m1 '$$pcport' $inf_file | cut -f2 -d '='` schema=`grep -m1 '$$dbschema' $inf_file | cut -f2 -d '='` passwd=`grep -m1 '$$dbpassword' $inf_file | cut -f2 -d '='` db=`grep -m1 '$$dbname' $inf_file | cut -f2 -d '='` location=`grep -m1 '$$location' $inf_file | cut -f2 -d '='` arch_dir=${pm_home}/scriptlogs/${location} dynamic_pf=`grep -m1 '$$parameterfile' $param_file dynamic_pf=${dir}/${dynamic_pf}
| cut -f2 -d '='`
execution_list=`grep -m1 '$$executionorderlist' $param_file execution_list=${dir}/${execution_list} prc_process_id=`grep -m1 '$$prcprocessid' ${dynamic_pf} creation_date=`date +%y%m%d%h%m%s`_$$ status=0
| cut -f2 -d '='`
| cut -f2 -d '='`
# executionorderlist is generated from mapping and format is: processid executionorder
task_list=${dir}/tasklist_$creation_date log_file=${dir}/log_seq_$creation_date spool_file=${dir}/spool_$creation_date.lst # ifs=";" echo "pc server : $pc_server (port: $port)" echo "database : $db/$schema" echo "archive directory: $arch_dir " echo "working dir: $dir" echo "start parameter file: $param_file" echo "dynamic parameter file: $dynamic_pf" echo "executionorderlist: $execution_list" echo " task execution list for prcprocess=${prc_process_id}" > $task_list echo "" >> $task_list echo " log file on `date +%y.%m.%d` for the prc_process_id=${prc_process_id}" > $log_file echo "pc server : $pc_server (port: $port)" >> $log_file echo "archive directory: $arch_dir " >> $log_file echo "database : $db/$schema" >> $log_file echo "working dir: $dir" >> $log_file echo "start parameter file: $param_file" >> $log_file echo "dynamic parameter file: $dynamic_pf" >> $log_file echo "executionorderlist: $execution_list" >> $log_file cat ${execution_list} | while read process_id execution_order; do echo "******" >> $log_file echo "processid $process_id" >> $log_file echo "executionorder $execution_order" >> $log_file # set run indicator to 'y' xx=`sqlplus /nolog << eom connect ${schema}/${passwd}@${db} set linesize 200 set serveroutput on spool $spool_file exec pkg_gateway.p_set_task_run_ind(${prc_process_id}, ${process_id},${execution_order}, 3, 1200); spool off exit; eom` echo "spool file: $spool_file" >> $log_file echo "----------" >> $log_file cat $spool_file >> $log_file echo "----------" >> $log_file # check errors in spool file xx= `grep internal_error $spool_file` if [ x"$xx" != x ]; then echo "error in call of procedure pkg_gateway.p_set_task_run_ind"; echo error >> $task_list; status=1; exit 1; fi creation_date=`date +%y.%m.%d.%h:%m:%s` xx=`grep "skip_wf" $spool_file` if [ x"$xx" != x ] then echo " $creation_date skiping wf. processnr: ${process_id} exec.order:
${execution_order} " >>$log_file echo " $creation_date skiping wf. processnr: ${process_id} exec.order: ${execution_order} " >>$task_list else # logging set `grep "task_exec_order ${process_id} ${execution_order}" $spool_file | awk '{print $4, $5, $6}'` task_id=$1 pc_workflow=$2 pc_folder=$3 echo $creation_date : processid=$process_id executionorder=$execution_order taskid=$task_id folder=$pc_folder workflow=$pc_workflow >> $task_list # start workflow # echo "starting: pmcmd startworkflow -s ${pc_server}:${port} -u ${pc_appl_user} -paramfile ${dynamic_pf}-p ${pc_appl_password} -f ${pc_folder} ${pc_workflow} " echo " $creation_date starting: pmcmd startworkflow -s ${pc_server}:${port} -u administrator -paramfile ${dynamic_pf} -pv pm_pass -f ${pc_folder} ${pc_workflow} " >>$log_file # pmcmd startworkflow -s ${pc_server}:${port} -u ${pc_appl_user} -paramfile ${dynamic_pf} -p ${pc_appl_password} -f ${pc_folder} ${pc_workflow} pmcmd startworkflow -s ${pc_server}:${port} -u administrator -paramfile ${dynamic_pf} -pv pm_pass -f ${pc_folder} ${pc_workflow} status=$? if [ $status != 0 ]; then echo "error by start of wf ${pc_workflow}" >> $task_list; echo "error by start of wf ${pc_workflow}" >> $log_file; run_status=error; else run_status=running; fi wf_status_spool=${dir}/${pc_folder}_${pc_workflow}_${creation_date}.tmp # check workflow status every 2 sec. # run_status=running while [ "${run_status}" = "running" ]; do sleep 2 echo "pmcmd getworkflowdetails -s ${pc_server}:${port} -u administrator -pv pm_pass -f ${pc_folder} ${pc_workflow} > ${wf_status_spool}" >>$log_file pmcmd getworkflowdetails -s ${pc_server}:${port} -u administrator -pv pm_pass -f ${pc_folder} ${pc_workflow} > ${wf_status_spool} run_status=`grep 'workflow run status:' ${wf_status_spool} | cut -f2 -d '[' | cut -f1 -d ']'` echo " run status: ${run_status}" >> $log_file done echo "final status: ${run_status}" >> $log_file echo "final status: ${run_status}" >> $task_list rm ${wf_status_spool} # set run indicator to 'n' yy=`sqlplus /nolog << eom connect ${schema}/${passwd}@${db} set linesize 200 spool $spool_file exec pkg_gateway.p_unset_task_run_ind(${process_id},${execution_order}); spool off exit; eom` echo "set taskstateflag to n for process/execorader
(${process_id}/${execution_order}) to 'n' ">> $log_file cat $spool_file >> $log_file # check errors in spool file xx= `grep internal_error $spool_file` if [ x"$xx" != x ]; then echo "error in call of a procedure pkg_gateway.p_unset_task_run_ind"; echo error >> $task_list; exit 1; fi rm $spool_file if [ "${run_status}" != "succeeded" ]; then echo "error by execution!" >> $task_list; status=1; exit 1; fi # if [ "${run_status}" = "failed" ]; then echo "workflow executer with error."; echo error >> $task_list; status=1; exit 1; fi fi # end of skeep/exec if done status=$? echo "process finished on `date '+%y.%m.%d.%h:%m:%s'`" >> $log_file mv mv mv cp
$log_file $arch_dir/${prc_process_id}_log_seq_${creation_date} $task_list $arch_dir/${prc_process_id}_tasklist_$creation_date $spool_file $arch_dir/${prc_process_id}_spool_$creation_date.lst $param_file $arch_dir/${prc_process_id}_${file_name}_${creation_date}
exit $status