-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactoring the launch scripts to follow common service interface (st…
…art|stop|status)
- Loading branch information
1 parent
81f3463
commit b1128cf
Showing
8 changed files
with
244 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"64e266dfae2b4f34abf0de11ec077e99": {"storage_path": "C:/Users/cedricd/Desktop/test_rocrate_api\\test_rocrate_vliz", "ro_profile": "233ec883a63a4cf8965fb7fab08fe7c5", "uuid": "64e266dfae2b4f34abf0de11ec077e99", "remote_url": "", "workspace_path": "C:\\Users\\cedricd\\Documents\\GitHub\\rocrate-maker-fast-api\\backend\\app\\webtop-work-space\\spaces\\64e266dfae2b4f34abf0de11ec077e99"}, "5c64534759534c869ef98422b4ac2ca8": {"storage_path": "C:/Users/cedric/Desktop/no importante\\testuicrate", "ro_profile": "233ec883a63a4cf8965fb7fab08fe7c5", "uuid": "5c64534759534c869ef98422b4ac2ca8", "remote_url": "", "workspace_path": "C:\\Users\\cedric\\Documents\\GitHub\\rocrate-maker-fast-api\\backend\\app\\webtop-work-space\\spaces\\5c64534759534c869ef98422b4ac2ca8"}, "cb291365244a4720b530158493386535": {"storage_path": "C:/Users/cedricd/Desktop/test_rocrate_api\\test_osd_good_profile", "ro_profile": "3b1020e07f6640b4bb97766e62c7708a", "uuid": "cb291365244a4720b530158493386535", "remote_url": "https://github.com/vliz-be-opsci/test_OSD_datacrate", "workspace_path": "C:\\Users\\cedricd\\Documents\\GitHub\\rocrate-maker-fast-api\\backend\\app\\webtop-work-space\\spaces\\cb291365244a4720b530158493386535"}, "fc7aa54fd2274e9eaea4a997a550ffd2": {"storage_path": "C:/Users/cedric/Desktop/no importante\\test_osd_home_pc", "ro_profile": "3b1020e07f6640b4bb97766e62c7708a", "uuid": "fc7aa54fd2274e9eaea4a997a550ffd2", "remote_url": "https://github.com/vliz-be-opsci/test_OSD_datacrate.git", "workspace_path": "C:\\Users\\cedric\\Documents\\GitHub\\rocrate-maker-fast-api\\backend\\app\\webtop-work-space\\spaces\\fc7aa54fd2274e9eaea4a997a550ffd2"}, "eab2ad566ca04102a2fe2eddee5624f0": {"storage_path": "C:/Users/cedricd/Desktop/test_rocrate_api\\OSD2014", "ro_profile": "3b1020e07f6640b4bb97766e62c7708a", "uuid": "eab2ad566ca04102a2fe2eddee5624f0", "remote_url": "https://github.com/ocean-sampling-day/OSD2014", "workspace_path": "C:\\Users\\cedricd\\Documents\\GitHub\\rocrate-maker-fast-api\\backend\\app\\webtop-work-space\\spaces\\eab2ad566ca04102a2fe2eddee5624f0"}, "48b9f7113eb6409e825d4a2541e2c925": {"storage_path": "C:/Users/cedricd/Desktop/test_rocrate_api\\OSD2018", "ro_profile": "3b1020e07f6640b4bb97766e62c7708a", "uuid": "48b9f7113eb6409e825d4a2541e2c925", "remote_url": "https://github.com/ocean-sampling-day/OSD2018", "workspace_path": "C:\\Users\\cedricd\\Documents\\GitHub\\rocrate-maker-fast-api\\backend\\app\\webtop-work-space\\spaces\\48b9f7113eb6409e825d4a2541e2c925"}, "782c733125b543019ef859a04a85d7f2": {"storage_path": "C:/Users/cedricd/Desktop/test_rocrate_api\\OSD2019", "ro_profile": "3b1020e07f6640b4bb97766e62c7708a", "uuid": "782c733125b543019ef859a04a85d7f2", "remote_url": "https://github.com/ocean-sampling-day/OSD2019", "workspace_path": "C:\\Users\\cedricd\\Documents\\GitHub\\rocrate-maker-fast-api\\backend\\app\\webtop-work-space\\spaces\\782c733125b543019ef859a04a85d7f2"}, "d628dc396f3647398c23233959cac09e": {"storage_path": "C:/Users/cedric/Desktop/no importante\\osd2014home", "ro_profile": "3b1020e07f6640b4bb97766e62c7708a", "uuid": "d628dc396f3647398c23233959cac09e", "remote_url": "https://github.com/ocean-sampling-day/OSD2014", "workspace_path": "C:\\Users\\cedric\\Documents\\GitHub\\rocrate-maker-fast-api\\backend\\app\\webtop-work-space\\spaces\\d628dc396f3647398c23233959cac09e"}} | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#! /usr/bin/env bash | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
cd ${SCRIPT_DIR} | ||
|
||
PIDFILE="backend.pid" | ||
|
||
function dependencies { | ||
#check if there is a venv folder already in the directory | ||
if [ ! -d venv ]; then | ||
echo "No venv directory exists in the directory." | ||
# if there is no venv folder, create one with python virtualenv | ||
echo "Creating a new venv folder..." | ||
python -m venv venv | ||
else | ||
echo "A venv directory already exists in the directory." | ||
fi | ||
|
||
#activate the venv | ||
if [ -f venv/Scripts/activate ]; then | ||
source venv/Scripts/activate | ||
fi | ||
if [ -f venv/bin/activate ]; then | ||
source venv/bin/activate | ||
fi | ||
|
||
pip install -r requirements.txt | ||
} | ||
|
||
function start_service { | ||
#open the browser | ||
python -m webbrowser http://localhost:6656/apiv1/redoc | ||
python -m webbrowser http://localhost:6656/apiv1/docs | ||
#run the server | ||
uvicorn app.app:app --reload --port 6656 --host 0.0.0.0 & | ||
echo -n $! > $PIDFILE | ||
} | ||
|
||
function stop_service { | ||
kill $(cat ${PIDFILE}) | ||
rm ${PIDFILE} >> /dev/null | ||
} | ||
|
||
function check_service { | ||
local running="1" | ||
if [ -f ${PIDFILE} ] ; then | ||
local pid=$(cat ${PIDFILE}) | ||
ps -p ${pid} >/dev/null 2>&1 | ||
running=$? | ||
if [ "$running" != "0" ] ; then | ||
echo "available pid '${pid}' does not seem to be running -- removing ${PIDILE}" >&2 | ||
rm ${PIDFILE} > /dev/null | ||
else | ||
echo "process '${pid}' running" >&2 | ||
fi | ||
else | ||
echo "No pid available in ${PIDFILE} - assume service is not running" >&2 | ||
fi | ||
echo ${running} | ||
} | ||
|
||
|
||
# check run argument | ||
|
||
case ${1} in | ||
|
||
start) | ||
echo "request to start..." | ||
if [ "$(check_service)" == "0" ] ; then | ||
echo "Backend Service ($(cat ${PIDFILE})) is running. Visit http://localhost:6656/" | ||
else | ||
echo "Backend Service is not running. Will start it now." | ||
dependencies | ||
start_service | ||
echo "Backend Service started as pid $(cat ${PIDFILE})" | ||
fi | ||
;; | ||
|
||
stop) | ||
echo "request to stop..." | ||
if [ "$(check_service)" == "0" ] ; then | ||
echo "Backend Service ($(cat ${PIDFILE})) is running. Stopping now." | ||
stop_service | ||
else | ||
echo "Backend Service is not running. Nothing to stop. Check ps -ef | grep uvicorn" | ||
fi | ||
;; | ||
|
||
status) | ||
if [ "$(check_service)" == "0" ] ; then | ||
echo "Backend Service ($(cat ${PIDFILE})) is running. Visit http://localhost:6656/" | ||
else | ||
echo "Backend Service is not running" | ||
fi | ||
;; | ||
|
||
*) | ||
echo "Usage: ${0} start|stop|status" | ||
exit 1 | ||
;; | ||
|
||
esac | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#! /usr/bin/env bash | ||
|
||
# federate start | stop | status service requests for the front-backend service combo | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
|
||
function service_request { | ||
srvrq=${1} | ||
for srv in "backend" "frontend"; do | ||
script="${SCRIPT_DIR}/${srv}/${srv}-service.sh" | ||
if [ ! -x ${script} ]; then | ||
echo "script at ${script} does not exist or is not executable" >&2 | ||
fi | ||
echo "${script} ${srvrq} &" | bash | ||
echo "'$srv' service requested for '${srvrq}'" | ||
echo | ||
done | ||
} | ||
|
||
|
||
# check cli argument and feed it into the federated services | ||
|
||
case ${1} in | ||
start|stop|status) | ||
service_request $1 | ||
;; | ||
|
||
*) | ||
echo "Usage: ${0} start|stop|status" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#! /usr/bin/env bash | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
cd ${SCRIPT_DIR} | ||
|
||
PIDFILE="frontend.pid" | ||
|
||
function dependencies { | ||
# first see if node is installed on the users system | ||
node -v | ||
if [ $? -ne 0 ]; then | ||
echo "Node.js is not installed on your system." | ||
echo "Please install Node.js and try again." | ||
exit 1 | ||
fi | ||
|
||
echo "Node.js is installed on your system." | ||
echo "Installing frontend dependencies..." | ||
npm install | ||
|
||
echo "building the local one pager web site" | ||
./frontend-build.sh | ||
|
||
echo "installing local webserver srevice" | ||
npm install -g serve | ||
} | ||
|
||
|
||
function start_service { | ||
echo "React.js is installed on your system." | ||
echo "Running frontend..." | ||
python -m webbrowser http://localhost:3000/ | ||
serve -s build -l 3000 & | ||
echo -n $! > $PIDFILE | ||
} | ||
|
||
|
||
function stop_service { | ||
kill $(cat ${PIDFILE}) | ||
rm ${PIDFILE} >> /dev/null | ||
} | ||
|
||
function check_service { | ||
local running="1" | ||
if [ -f ${PIDFILE} ] ; then | ||
local pid=$(cat ${PIDFILE}) | ||
ps -p ${pid} >/dev/null 2>&1 | ||
running=$? | ||
if [ "$running" != "0" ] ; then | ||
echo "available pid '${pid}' does not seem to be running -- removing ${PIDILE}" >&2 | ||
rm ${PIDFILE} > /dev/null | ||
else | ||
echo "process '${pid}' running" >&2 | ||
fi | ||
else | ||
echo "No pid available in ${PIDFILE} - assume service is not running" >&2 | ||
fi | ||
echo ${running} | ||
} | ||
|
||
|
||
# check run argument | ||
|
||
case ${1} in | ||
|
||
start) | ||
echo "request to start..." | ||
if [ "$(check_service)" == "0" ] ; then | ||
echo "Frontend Service ($(cat ${PIDFILE})) is running. Visit http://localhost:3000/" | ||
else | ||
echo "Frontend Service is not running. Will start it now." | ||
dependencies | ||
start_service | ||
echo "Frontend Service started as pid $(cat ${PIDFILE})" | ||
fi | ||
;; | ||
|
||
stop) | ||
echo "request to stop..." | ||
if [ "$(check_service)" == "0" ] ; then | ||
echo "Frontend Service ($(cat ${PIDFILE})) is running. Stopping now." | ||
stop_service | ||
else | ||
echo "Frontend Service is not running. Nothing to stop. Check ps -ef | grep uvicorn" | ||
fi | ||
;; | ||
|
||
status) | ||
if [ "$(check_service)" == "0" ] ; then | ||
echo "Frontend Service ($(cat ${PIDFILE})) is running. Visit http://localhost:3000/" | ||
else | ||
echo "Frontend Service is not running" | ||
fi | ||
;; | ||
|
||
*) | ||
echo "Usage: ${0} start|stop|status" | ||
exit 1 | ||
;; | ||
|
||
esac | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
#! /usr/bin/env bash | ||
|
||
# open multiple terminals and execute the following commands: | ||
# cd /Users/<username>/webtop/frontend | ||
# sh frontend_run.sh | ||
# cd /Users/<username>/webtop/backend | ||
# sh start-api-server.sh | ||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
cd ${SCRIPT_DIR} | ||
|
||
(cd backend/ && sh start-api-server.sh & ) # the & is to run the command in the background | ||
(cd frontend/ && sh frontend_run.sh & ) | ||
./dmbon-assistant.sh start |