mirror of
https://github.com/FakeTV/pseudo-channel.git
synced 2026-01-07 10:43:14 +00:00
Updates to scripts.
This commit is contained in:
48
startstop.sh
48
startstop.sh
@@ -13,35 +13,57 @@
|
||||
|
||||
#----BEGIN EDITABLE VARS----
|
||||
|
||||
pid_file=running.pid
|
||||
SCRIPT_TO_EXECUTE_PLUS_ARGS='PseudoChannel.py -m -r'
|
||||
|
||||
output_pid_path=.
|
||||
OUTPUT_PID_FILE=running.pid
|
||||
|
||||
python_to_use="$(which python)"
|
||||
OUTPUT_PID_PATH=.
|
||||
|
||||
PYTHON_TO_USE="$(which python)"
|
||||
|
||||
# If using 'virtualenv' with python, specify the local virtualenv dir.
|
||||
VIRTUAL_ENV_DIR="env"
|
||||
|
||||
#----END EDITABLE VARS-------
|
||||
|
||||
if [ ! -e $output_pid_path/$pid_file ]; then
|
||||
if [ -d "$VIRTUAL_ENV_DIR" ]; then
|
||||
|
||||
PYTHON_TO_USE="$VIRTUAL_ENV_DIR/bin/python"
|
||||
|
||||
fi
|
||||
|
||||
if [ ! -e "$OUTPUT_PID_PATH/$OUTPUT_PID_FILE" ]; then
|
||||
|
||||
# If the running.pid file doesn't exists, create it, start PseudoChannel.py and add the PID to it.
|
||||
nohup $python_to_use ./PseudoChannel.py -m -r > /dev/null 2>&1 & echo $! > $output_pid_path/$pid_file
|
||||
"$PYTHON_TO_USE" ./$SCRIPT_TO_EXECUTE_PLUS_ARGS > /dev/null 2>&1 & echo $! > "$OUTPUT_PID_PATH/$OUTPUT_PID_FILE"
|
||||
|
||||
echo "Started $SCRIPT_TO_EXECUTE_PLUS_ARGS @ Process: $!"
|
||||
|
||||
echo "Started PseudoChannel.py @ Process: $!"
|
||||
sleep .7
|
||||
echo "Created $pid_file file in $output_pid_path dir"
|
||||
|
||||
echo "Created $OUTPUT_PID_FILE file in $OUTPUT_PID_PATH dir"
|
||||
|
||||
else
|
||||
|
||||
# If the running.pid exists, read it & try to kill the process if it exists, then delete it.
|
||||
the_pid=$(<$output_pid_path/$pid_file)
|
||||
rm $output_pid_path/$pid_file
|
||||
echo "Deleted $pid_file file in $output_pid_path dir"
|
||||
kill $the_pid
|
||||
the_pid=$(<$OUTPUT_PID_PATH/$OUTPUT_PID_FILE)
|
||||
|
||||
rm "$OUTPUT_PID_PATH/$OUTPUT_PID_FILE"
|
||||
|
||||
echo "Deleted $OUTPUT_PID_FILE file in $OUTPUT_PID_PATH dir"
|
||||
|
||||
kill "$the_pid"
|
||||
|
||||
while [ -e /proc/$the_pid ]
|
||||
|
||||
do
|
||||
echo "PseudoChannel.py @: $the_pid is still running"
|
||||
|
||||
echo "$SCRIPT_TO_EXECUTE_PLUS_ARGS @: $the_pid is still running"
|
||||
|
||||
sleep .7
|
||||
|
||||
done
|
||||
echo "PseudoChannel.py @: $the_pid has finished"
|
||||
|
||||
echo "$SCRIPT_TO_EXECUTE_PLUS_ARGS @: $the_pid has finished"
|
||||
|
||||
fi
|
||||
Reference in New Issue
Block a user