From 246e1e8bd78cfceb277f0dc88765e4598a0ed8bf Mon Sep 17 00:00:00 2001 From: David Brazda Date: Thu, 13 Apr 2023 11:35:11 +0200 Subject: [PATCH] ok --- runstop.sh | 89 +++++++++++++++++++ strat.log | 18 ++++ v2realbot/__pycache__/config.cpython-310.pyc | Bin 2465 -> 2465 bytes 3 files changed, 107 insertions(+) create mode 100755 runstop.sh create mode 100644 strat.log diff --git a/runstop.sh b/runstop.sh new file mode 100755 index 0000000..ec3e8f8 --- /dev/null +++ b/runstop.sh @@ -0,0 +1,89 @@ +#!/bin/bash + +# file: runstop.sh + +#---- +# Simple script to start / stop a python script in the background. +#---- + +#---- +# To Use: +# Just run: "./startstop.sh". If the process is running it will stop it or it will start it if not. +#---- + +#----BEGIN EDITABLE VARS---- + +SCRIPT_TO_EXECUTE_PLUS_ARGS='v2realbot/main.py -u' + +OUTPUT_PID_FILE=running.pid + +OUTPUT_PID_PATH=. + +PYTHON_TO_USE="python3" + +# If using 'virtualenv' with python, specify the local virtualenv dir. +#VIRTUAL_ENV_DIR="" + +#----END EDITABLE VARS------- + +# If virtualenv specified & exists, using that version of python instead. +if [ -d "$VIRTUAL_ENV_DIR" ]; then + + PYTHON_TO_USE="$VIRTUAL_ENV_DIR/bin/python" + +fi + +# If the .pid file doesn't exist (let's assume no processes are running)... +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. + "$PYTHON_TO_USE" ./$SCRIPT_TO_EXECUTE_PLUS_ARGS > strat.log 2>&1 & echo $! > "$OUTPUT_PID_PATH/$OUTPUT_PID_FILE" + + echo "Started $SCRIPT_TO_EXECUTE_PLUS_ARGS @ Process: $!" + + sleep .7 + + 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/$OUTPUT_PID_FILE) + + rm "$OUTPUT_PID_PATH/$OUTPUT_PID_FILE" + + echo "Deleted $OUTPUT_PID_FILE file in $OUTPUT_PID_PATH dir" + + kill "$the_pid" + + COUNTER=1 + + while [ -e /proc/$the_pid ] + + do + + echo "$SCRIPT_TO_EXECUTE_PLUS_ARGS @: $the_pid is still running" + + sleep .7 + + COUNTER=$[$COUNTER +1] + + if [ $COUNTER -eq 20 ]; then + + kill -9 "$the_pid" + + fi + + if [ $COUNTER -eq 40 ]; then + + exit 1 + + fi + + done + + echo "$SCRIPT_TO_EXECUTE_PLUS_ARGS @: $the_pid has finished" + +fi + +exit 0 \ No newline at end of file diff --git a/strat.log b/strat.log new file mode 100644 index 0000000..fc99100 --- /dev/null +++ b/strat.log @@ -0,0 +1,18 @@ +INFO: Started server process [55121] +INFO: Waiting for application startup. +INFO: Application startup complete. +INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) +INFO: 127.0.0.1:61741 - "GET / HTTP/1.1" 304 Not Modified +INFO: 127.0.0.1:61741 - "GET /stratins/?_=1681378496498 HTTP/1.1" 200 OK +INFO: 127.0.0.1:61741 - "GET /runners/?_=1681378496499 HTTP/1.1" 200 OK +INFO: 127.0.0.1:61741 - "GET /stratins/?_=1681378496500 HTTP/1.1" 200 OK +INFO: 127.0.0.1:61742 - "GET /runners/?_=1681378496501 HTTP/1.1" 200 OK +INFO: 127.0.0.1:61741 - "GET / HTTP/1.1" 304 Not Modified +INFO: 127.0.0.1:61741 - "GET /stratins/?_=1681378497526 HTTP/1.1" 200 OK +INFO: 127.0.0.1:61741 - "GET /runners/?_=1681378497527 HTTP/1.1" 200 OK +INFO: 127.0.0.1:61741 - "GET /stratins/?_=1681378497528 HTTP/1.1" 200 OK +INFO: 127.0.0.1:61742 - "GET /runners/?_=1681378497529 HTTP/1.1" 200 OK +INFO: Shutting down +INFO: Waiting for application shutdown. +INFO: Application shutdown complete. +INFO: Finished server process [55121] diff --git a/v2realbot/__pycache__/config.cpython-310.pyc b/v2realbot/__pycache__/config.cpython-310.pyc index cf676fee0dd6d28b9b7cdbf9e13cfeca8845ffb7..9de6df8bd49f394c876cb7fd2f51d8a719dc6e3c 100644 GIT binary patch delta 22 ccmZ1|yik}opO=@50SH>y%~Pgr