Retrieve LeafOutput operational

This commit is contained in:
2016-02-26 11:54:07 -05:00
parent 76722345a8
commit 59e2f9d8bd
14 changed files with 296 additions and 64 deletions
+28 -23
View File
@@ -1,12 +1,12 @@
#~/bin/bash
#!/bin/bash
# piscal manager script
usage="$(basename "$0") [-h] -d directory_name -f input_filename -- script to manage Piscal
usage="$(basename "$0") [-h] -d directory_name [-f input_filename|-s] -- script to manage Piscal
where:
-h show this help text
-d working directory name
-o input filename
-f input filename
-s job status"
# http://stackoverflow.com/a/14203146/99492
@@ -16,9 +16,10 @@ where:
base_directory="/home/poprhythm/LeafWeb"
directory_name=""
input_filename=""
get_status=false
task="start" # default task
pid_filename="piscal.pid"
out_filename="piscal.out"
launcher="$base_directory/piscal_launcher.sh"
while getopts "hd:f:s" opt; do
#echo "$opt = $OPTARG"
@@ -32,9 +33,10 @@ while getopts "hd:f:s" opt; do
;;
f )
input_filename=$OPTARG
task="start"
;;
s )
get_status=true
task="get_status"
;;
\?) printf "illegal option: -%s\n" "$OPTARG" >&2
echo "$usage" >&2
@@ -46,24 +48,30 @@ if [ -z "$directory_name" ]; then
echo "directory name required (-d)"
exit 1
fi
if [ ! -d "$base_directory/$directory_name" ]; then
echo "directory $base_directory/$directory_name not found"
working_directory="$base_directory/$directory_name"
if [ ! -d "$working_directory" ]; then
echo "directory $working_directory not found"
exit 1
fi
if [ "$get_status" = false ]; then
if [ "$task" = "start" ]; then
if [ -z "$input_filename" ]; then
echo "input filename required (-f)"
exit 1
fi
if [ ! -f "$base_directory/$directory_name/$input_filename" ]; then
echo "input filename $base_directory/$directory_name/$input_filename not found"
if [ ! -f "$working_directory/$input_filename" ]; then
echo "input filename $working_directory/$input_filename not found"
exit 1
fi
fi
command="$launcher -d $working_directory -f $input_filename"
nohup ${command} > $working_directory/$out_filename 2>&1 &
if [ "$get_status" = true ]; then
pid_path="$base_directory/$directory_name/$pid_filename"
# write the PID to a temp file to check for completion later
echo $! > $working_directory/$pid_filename
echo started
elif [ "$task" = "get_status" ]; then
pid_path="$working_directory/$pid_filename"
# if the pid doesn't exist, then process never started
if [ ! -f "$pid_path" ]; then
@@ -79,15 +87,12 @@ if [ "$get_status" = true ]; then
else
# otherwise, it is complete, check the output for success/error
# TODO: examine output for errors, etc
echo complete
#cat piscal.out
if [ ! -d "$working_directory/output" ]; then
echo "output directory $working_directory/output not found"
exit 1
fi
echo success
find "$working_directory/output"/*
fi
else
command="sleep 100s"
nohup ${command} > $base_directory/$directory_name/$out_filename 2>&1 &
# write the PID to a temp file to check for completion later
echo $! > $base_directory/$directory_name/$pid_filename
fi