-
Notifications
You must be signed in to change notification settings - Fork 0
/
server
executable file
·58 lines (56 loc) · 1.33 KB
/
server
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
#! /bin/bash
case "$1" in
start)
ps -ef | grep 3000 | grep puma
if [ $? -eq 1 ]
then
case "$2" in
develop)
echo "Startting server..."
bundle exec puma -C config/puma.rb
echo "Server running on port 3000 ;)!"
;;
*)
echo "Usage: server start {develop}" >&2
exit 1
;;
esac
else
echo "Server already running on port 3000 ;)!"
fi
;;
stop)
ps -ef | grep 3000 | grep puma
if [ $? -eq 1 ]
then
echo "Server is down."
else
echo "Stopping server..."
kill -9 $(lsof -i tcp:3000 -t)
echo "Server is down."
fi
;;
status)
ps -ef | grep 3000 | grep puma
if [ $? -eq 1 ]
then
echo "Server is down."
else
echo "Server running on port 3000 ;)!"
fi
;;
restart)
ps -ef | grep 3000 | grep puma
if [ $? -eq 1 ]
then
bundle exec puma -C config/puma.rb
else
kill -9 $(lsof -i tcp:3000 -t) && bundle exec puma -C config/puma.rb
fi
;;
*)
echo "Usage: server {start develop|stop|status|restart}" >&2
exit 1
;;
esac
exit 0