forked from ChrisHaPunkt/virtual-console
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.sh
executable file
·69 lines (57 loc) · 1.75 KB
/
app.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
case $1 in
'start' )
DIR=${PWD##*/}
echo `dirname $0`
if [ ${DIR} != "virtual-console" ]; then
cd "`dirname $0`"
fi
cd scripts
if [ "$(cat DBPID)" != "" ]; then
if kill -s 0 `cat DBPID`; then
echo "DB already running."
else
echo "No DB running"
echo "" > DBPID
pkill mongod
bash database.sh start
fi
else
bash database.sh start
fi
cd ..
DIR="NodeServer/node_modules"
if [ "$(ls -A ${DIR})" ]; then
echo " NodeModules present, starting app.."
else
echo "Prepare nodejs dependencies..."
bash scripts/prepareDeps.sh
fi
if [ "$(cat scripts/NODEPID)" != "" ]; then
if kill -s 0 `cat scripts/NODEPID`; then
echo "Node already running. Restarting"
echo "Stopping NodeJS..."
kill -INT `cat scripts/NODEPID`
echo "" > scripts/NODEPID
fi
fi
node NodeServer/bin/www &
PID=$!
echo ${PID} > scripts/NODEPID
# $SHELL
;;
'stop')
bash scripts/database.sh stop
echo "Stopping NodeJS..."
kill -INT `cat scripts/NODEPID`
echo "" > scripts/NODEPID
;;
'prepDeps')
echo "Prepare nodejs dependencies..."
bash scripts/prepareDeps.sh
;;
*)
echo 'usage $0 start | stop | prepDeps'
;;
esac
exit