-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev.sh
executable file
·66 lines (58 loc) · 1.3 KB
/
dev.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
#!/bin/bash -e
VM=debian
PID_FILE='tmp/pids/development.pid'
ALL_APPS="pandora"
RAILS_ENV=development
function usage {
echo "Usage:"
echo ""
echo " ./dev.sh <app> [<task>]"
echo ""
echo " Available apps: ${ALL_APPS[*]}"
echo " Use 'all' as app to start all apps daemonized."
echo ""
echo " Available tasks:"
echo " run: run app in foreground (default)"
echo " start: run app in background"
echo " stop: stop background app"
echo " restart: restart background app"
exit 1
}
function pandora {
TASK=$1
cd /vagrant/pandora
if [ $TASK == "run" ]; then
bundle exec rails s -p 3000 -b 0.0.0.0
elif [ $TASK == "start" ]; then
mkdir -p $(dirname $PID_FILE)
bundle exec rails s -p 3000 -b 0.0.0.0 -d -P $PID_FILE
elif [ $TASK == "stop" ]; then
kill_pid $(realpath $PID_FILE)
fi
}
function kill_pid {
FILE=$1
if [ -f $FILE ]; then
kill -9 $(cat $FILE)
rm $FILE
fi
}
if [ -z "$1" ] || [ "$1" == 'usage' ]; then
usage
fi
VARGS="$@"
if [ -d /vagrant ]; then
# echo "vagrant: $VARGS"
APPS=$1
TASK=${2:-run}
if [ "$APPS" == 'all' ]; then
APPS="$ALL_APPS"
fi
for APP in $APPS; do
echo "PROMETHEUS: $APP task: ${TASK}"
$APP $TASK || true
done
else
# echo "no vagrant: $VARGS"
vagrant ssh -c "cd /vagrant && ./dev.sh $VARGS"
fi