Allow scripts to be run from anywhere.

This commit is contained in:
Hyperling 2023-03-07 06:15:44 -06:00
parent b290e838de
commit e4b5e7d7d5
3 changed files with 29 additions and 9 deletions

19
run.sh
View File

@ -3,6 +3,13 @@
# Developer: Hyperling
# Purpose: Install all dependencies and run the project.
DIR=`dirname $0`
PROG=`basename $0`
if [[ $DIR == "." ]]; then
DIR="`pwd`"
echo $DIR/$PROG
fi
## Install any system packages. ##
if [[ -z `which npm` ]]; then
echo "NPM needs to be installed."
@ -20,8 +27,8 @@ fi
## Install/update any project modules. ##
echo "Refreshing NPM packages."
bash -c "rm -r node_modules package-lock.json"
npm install package.json
bash -c "rm -r $DIR/node_modules $DIR/package-lock.json"
npm install $DIR
## Main ##
@ -29,11 +36,11 @@ npm install package.json
if [[ $parent ]]; then
# Start backend
node `pwd`/server.js >server.log 2>&1 &
node $DIR/server.js >$DIR/logs/server.log 2>&1 &
else
# Start frontend.
tsc index.tsx
# ??? `pwd`/dist/index.js >ui.log 2>&1
tsc --project $DIR
# ??? $DIR/dist/index.js >$DIR/logs/ui.log 2>&1
fi
# Or just run them each with & and then kill with another shell script?
# Or just run them each with & and then kill with another shell script? stop.sh

12
stop.sh Normal file → Executable file
View File

@ -3,11 +3,17 @@
# Developer: Hyperling
# Purpose: Turn off the project since the subprocesses run as forks.
DIR=`dirname $0`
PROG=`basename $0`
if [[ $DIR == "." ]]; then
DIR="`pwd`"
echo $DIR/$PROG
fi
## Stop all services. ##
# Kill frontend.
# killall `pwd`/index.tsx >stop.log 2>&1
# killall $DIR//index.tsx >$DIR/logs/stop.log 2>&1
# Kill backend
killall `pwd`/server.js >stop.log 2>&1
killall $DIR/server.js >$DIR/logs/stop.log 2>&1

7
test.sh Normal file → Executable file
View File

@ -3,6 +3,13 @@
# Developer: Hyperling
# Purpose: Create a test user and some test data.
DIR=`dirname $0`
PROG=`basename $0`
if [[ $DIR == "." ]]; then
DIR="`pwd`"
echo $DIR/$PROG
fi
## Create User ##
# curl POST test_user test_password etc etc