From 0bebfe8a21567ef9f63146d471864561f227820f Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Sun, 2 Apr 2023 21:28:23 -0400 Subject: [PATCH] add start.sh --- pygeoweaver/detail_workflow.py | 6 ++++++ pygeoweaver/geoweaver.log | 1 + pygeoweaver/list_hosts.py | 5 +++++ pygeoweaver/list_processes.py | 5 +++++ pygeoweaver/list_workflows.py | 2 ++ pygeoweaver/run_workflow.py | 6 ++++++ pygeoweaver/server.py | 9 +++++++-- pygeoweaver/start.sh | 31 +++++++++++++++++++++++++++++-- pygeoweaver/stop.sh | 0 test/test_all.py | 0 10 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 pygeoweaver/geoweaver.log mode change 100644 => 100755 pygeoweaver/start.sh mode change 100644 => 100755 pygeoweaver/stop.sh create mode 100644 test/test_all.py diff --git a/pygeoweaver/detail_workflow.py b/pygeoweaver/detail_workflow.py index e69de29..46219b4 100644 --- a/pygeoweaver/detail_workflow.py +++ b/pygeoweaver/detail_workflow.py @@ -0,0 +1,6 @@ + + + +def detail_workflow(): + print("Show details of a workflow") + pass \ No newline at end of file diff --git a/pygeoweaver/geoweaver.log b/pygeoweaver/geoweaver.log new file mode 100644 index 0000000..ae5d108 --- /dev/null +++ b/pygeoweaver/geoweaver.log @@ -0,0 +1 @@ +Error: Unable to access jarfile geoweaver.jar diff --git a/pygeoweaver/list_hosts.py b/pygeoweaver/list_hosts.py index e69de29..e05e379 100644 --- a/pygeoweaver/list_hosts.py +++ b/pygeoweaver/list_hosts.py @@ -0,0 +1,5 @@ + + +def list_hosts(): + print("List all hosts") + pass diff --git a/pygeoweaver/list_processes.py b/pygeoweaver/list_processes.py index e69de29..9e7a569 100644 --- a/pygeoweaver/list_processes.py +++ b/pygeoweaver/list_processes.py @@ -0,0 +1,5 @@ + + +def list_processes(): + print("all the geoweaver cli") + pass \ No newline at end of file diff --git a/pygeoweaver/list_workflows.py b/pygeoweaver/list_workflows.py index fd40910..5437f5c 100644 --- a/pygeoweaver/list_workflows.py +++ b/pygeoweaver/list_workflows.py @@ -1,4 +1,6 @@ +def list_workflows(): + pass diff --git a/pygeoweaver/run_workflow.py b/pygeoweaver/run_workflow.py index e69de29..dd46255 100644 --- a/pygeoweaver/run_workflow.py +++ b/pygeoweaver/run_workflow.py @@ -0,0 +1,6 @@ + + + +def run_workflow(): + print("Run workflow: ") + pass \ No newline at end of file diff --git a/pygeoweaver/server.py b/pygeoweaver/server.py index b8ae7d7..704db63 100644 --- a/pygeoweaver/server.py +++ b/pygeoweaver/server.py @@ -8,17 +8,22 @@ """ +def download_geoweaver(): + """ + Download Geoweaver to user home directory + """ + def start(): print("start Geoweaver instance..") - result = subprocess.run(['java', '-jar', 'geoweaver.jar'], capture_output=True, text=True) + result = subprocess.run(['start.sh'], capture_output=True, text=True) print(result.stdout) print(result.stderr) def stop(): print("stop Geoweaver instance..") - result = subprocess.run(['java', '-jar', 'geoweaver.jar'], capture_output=True, text=True) + result = subprocess.run(['stop.sh'], capture_output=True, text=True) print(result.stdout) print(result.stderr) diff --git a/pygeoweaver/start.sh b/pygeoweaver/start.sh old mode 100644 new mode 100755 index fcee7fa..8bb83ef --- a/pygeoweaver/start.sh +++ b/pygeoweaver/start.sh @@ -1,5 +1,32 @@ #!/bin/bash -wget https://github.com/ESIPFed/Geoweaver/releases/download/latest/geoweaver.jar -O ~/ +FILE=~/geoweaver.jar +if [ -f "$FILE" ]; then + echo "$FILE exists. Skip downloading.." +else + echo "Downloading the latest geoweaver.jar to user home directory" + cd ~ && curl -OL https://github.com/ESIPFed/Geoweaver/releases/download/latest/geoweaver.jar +fi -java -jar ~/geoweaver.jar \ No newline at end of file +echo "Stop running Geoweaver if any.." +kill $(ps aux | grep 'geoweaver.jar' | awk '{print $2}') + +echo "Start Geoweaver.." +nohup java -jar ~/geoweaver.jar > ~/geoweaver.log & + +STATUS=0 +counter=0 +until [ $STATUS == 302 ] || [ $counter == 20 ] +do + sleep 2 + STATUS=$(curl -s -o /dev/null -w "%{http_code}\n" "http://localhost:8070/Geoweaver") + ((counter++)) +done + +if [ $counter == 20 ] ; then + echo "Error: Geoweaver is not up" + exit 1 +else + echo "Success: Geoweaver is up" + exit 0 +fi \ No newline at end of file diff --git a/pygeoweaver/stop.sh b/pygeoweaver/stop.sh old mode 100644 new mode 100755 diff --git a/test/test_all.py b/test/test_all.py new file mode 100644 index 0000000..e69de29