-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetiene
executable file
·36 lines (33 loc) · 931 Bytes
/
detiene
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
#!/bin/sh
# Detiene servicio
if (test -f ".env") then {
. .env
} fi;
if (test "$RC" = "") then {
echo "Falta RC en .env"
exit 1
} fi;
if (test "$RAILS_ENV" = "production") then {
if (test ! -f /etc/rc.d/$RC) then {
echo "Falta script /etc/rc.d/$RC"
exit 1;
} fi;
doas rcctl -d stop $RC
} elif (test "$RAILS_ENV" = "development") then {
# Intentando detener rails
if (test -f tmp/pids/server.pid) then {
pp=`cat tmp/pids/server.pid`
ps -p $pp | grep "ruby: puma" > /dev/null
if (test "$?" = "0") then {
# Proceso activo y con ruby y puma seguramente es el de este
echo "Matando proceso con rails $pp"
kill -9 $pp
} fi;
} fi;
# Intentand detener proceso de recarga viva
pn=`fstat | grep $PUERTORECVIVA | sed -e "s/^[^\s]* node *\([0-9][0-9]*\) .*/\1/g" | sort -u`
if (test "$pn" != "") then {
echo "Matando proceso con node $pn"
kill -9 $pn
} fi;
} fi;