This repository has been archived by the owner on Jan 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.dist
executable file
·153 lines (123 loc) · 2.88 KB
/
deploy.dist
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/tcsh
# http://j.shirley.im/tech/perl/start_server.html
### IMPORTANT APP CONFIGURATION ###
set APP_NAME=PrimoServices
set APP_PATH=/u1/apps/production/PrimoServices
set APP_INSTANCE=prod1
set WORKERS=40
### ###
setenv PLACK_ENV production
setenv PERLBREW_ROOT /u1/perl
if ( ! -d $PERLBREW_ROOT && ! -e $PERLBREW_ROOT/etc/cshrc ) then
echo "Perlbrew not found. Exiting ..."
exit 1
endif
source $PERLBREW_ROOT/etc/cshrc
perlbrew use perl-5.18.2
if ( ! -d $APP_PATH ) then
echo "App path not found: $APP_PATH. Exiting ..."
exit 1
endif
# Add ./perl5/lib/perl5 to PERL5LIB if exists (locally installed dependencies)
if ( -d "$APP_PATH/perl5/lib/perl5" ) then
setenv PERL5LIB "$APP_PATH/perl5/lib/perl5"
endif
# Use local or global start_server
if ( -f "$APP_PATH/perl5/bin/start_server" ) then
set DAEMON="$APP_PATH/perl5/bin/start_server"
else
# get from default path
set DAEMON=start_server
endif
# Use local or global starman
if ( -f "$APP_PATH/perl5/bin/starman" ) then
set SERVER="$APP_PATH/perl5/bin/starman"
else
# get from default path
set SERVER=starman
endif
set PID="$APP_PATH/$APP_NAME.pid"
set STATUS="$APP_PATH/$APP_NAME.status"
set DAEMON_OPTS="--pid-file=$PID --status-file=$STATUS"
set SOCKET="/tmp/starman_$APP_NAME-$APP_INSTANCE.sock"
set ERROR_LOG="$APP_PATH/logs/$APP_NAME.error.log"
switch ($1)
case start:
# stop already running daemons
if ( -e $PID ) then
$0 stop
sleep 5
# cleanup if it is leftovers from a crash
if ( -e $PID ) then
rm -f $PID
endif
if ( -e $STATUS ) then
rm -f $STATUS
endif
endif
echo "Starting: $APP_NAME"
# start daemon
$DAEMON $DAEMON_OPTS -- $SERVER --listen $SOCKET --workers $WORKERS --error-log $ERROR_LOG $APP_PATH/bin/app.pl &
sleep 3
chmod 666 $SOCKET
breaksw
case stop:
if ( -e $PID ) then
echo "Stopping: $APP_NAME"
kill -TERM `cat $PID`
sleep 2
endif
breaksw
case restart:
if ( -e $PID ) then
echo "Restarting: $APP_NAME"
$0 stop
$0 start
exit 0
else
$0 start
exit 0
endif
breaksw
case update:
set PWD = `pwd`
cd $APP_PATH
fossil update
cd $PWD
$0 restart
breaksw
case installdeps:
set PWD = `pwd`
cd $APP_PATH
cpanm -L perl5 --installdeps .
cd $PWD
breaksw
case status:
echo "Server process(es) for: $APP_NAME"
if ( -e $STATUS ) then
cat $STATUS
else
echo "Not running!"
endif
breaksw
case server-status:
$APP_PATH/perl5/bin/server-status --scoreboard $APP_PATH/server-status --counter $APP_PATH/server-status/counter
breaksw
case development:
if ( -e $STATUS ) then
$0 restart
endif
if ( $2 != '' ) then
set PORT=$2
else
set PORT=8080
endif
setenv PLACK_ENV development
set WATCH_FOLDERS='./lib,config.yml'
plackup -R $WATCH_FOLDERS --server Starman --host `hostname` --port $PORT bin/app.pl
breaksw
default:
echo "Usage: $0 {start|stop|restart|update|installdeps|status|server-status|development}"
exit 1
endsw
exit 0