k2hr3-api 1.0.21 → 1.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog +12 -0
- package/bin/run.sh +61 -19
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
k2hr3-api (1.0.23) unstable; urgency=low
|
|
2
|
+
|
|
3
|
+
* Re-fixed a bug about stopping processes in run.sh - #96
|
|
4
|
+
|
|
5
|
+
-- Takeshi Nakatani <ggtakec@gmail.com> Thu, 01 Jun 2023 19:58:08 +0900
|
|
6
|
+
|
|
7
|
+
k2hr3-api (1.0.22) unstable; urgency=low
|
|
8
|
+
|
|
9
|
+
* Fixed a bug about stopping processes in run.sh - #94
|
|
10
|
+
|
|
11
|
+
-- Takeshi Nakatani <ggtakec@gmail.com> Thu, 01 Jun 2023 15:37:41 +0900
|
|
12
|
+
|
|
1
13
|
k2hr3-api (1.0.21) unstable; urgency=low
|
|
2
14
|
|
|
3
15
|
* Changed partially scripts(command) in package.json - #92
|
package/bin/run.sh
CHANGED
|
@@ -76,6 +76,44 @@ PrintUsage()
|
|
|
76
76
|
echo ""
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
#
|
|
80
|
+
# Using ALL_CHILD_PIDS global variable
|
|
81
|
+
#
|
|
82
|
+
get_all_pid_list()
|
|
83
|
+
{
|
|
84
|
+
if [ -z "${ALL_CHILD_PIDS}" ]; then
|
|
85
|
+
return 0
|
|
86
|
+
fi
|
|
87
|
+
_ADD_PIDS=0
|
|
88
|
+
for _ONE_PID in ${ALL_CHILD_PIDS}; do
|
|
89
|
+
if _CIHLD_PIDS=$(pgrep -P "${_ONE_PID}"); then
|
|
90
|
+
for _ONE_CPID in ${_CIHLD_PIDS}; do
|
|
91
|
+
_FOUND_PID=0
|
|
92
|
+
for _ONE_PPID in ${ALL_CHILD_PIDS}; do
|
|
93
|
+
if [ "${_ONE_CPID}" = "${_ONE_PPID}" ]; then
|
|
94
|
+
_FOUND_PID=1
|
|
95
|
+
break
|
|
96
|
+
fi
|
|
97
|
+
done
|
|
98
|
+
if [ "${_FOUND_PID}" -eq 0 ]; then
|
|
99
|
+
#
|
|
100
|
+
# Add child PID
|
|
101
|
+
#
|
|
102
|
+
ALL_CHILD_PIDS="${ALL_CHILD_PIDS} ${_ONE_CPID}"
|
|
103
|
+
_ADD_PIDS=1
|
|
104
|
+
fi
|
|
105
|
+
done
|
|
106
|
+
fi
|
|
107
|
+
done
|
|
108
|
+
if [ "${_ADD_PIDS}" -eq 1 ]; then
|
|
109
|
+
#
|
|
110
|
+
# Reentrant for check adding PIDs
|
|
111
|
+
#
|
|
112
|
+
get_all_pid_list
|
|
113
|
+
fi
|
|
114
|
+
return 0
|
|
115
|
+
}
|
|
116
|
+
|
|
79
117
|
#
|
|
80
118
|
# Stop processes
|
|
81
119
|
#
|
|
@@ -92,38 +130,42 @@ stop_old_process()
|
|
|
92
130
|
return 0
|
|
93
131
|
fi
|
|
94
132
|
|
|
95
|
-
|
|
133
|
+
ALL_CHILD_PIDS="$(tr -d '\n' < "${PROC_PID_FILE}")"
|
|
134
|
+
|
|
135
|
+
if pgrep -f "${PRGNAME}" | grep -q "${ALL_CHILD_PIDS}"; then
|
|
136
|
+
#
|
|
137
|
+
# List up all chid processes
|
|
138
|
+
#
|
|
139
|
+
get_all_pid_list
|
|
96
140
|
|
|
97
|
-
if pgrep -f "${PRGNAME}" | grep -q "${OLD_PID}"; then
|
|
98
141
|
#
|
|
99
142
|
# Try to stop(HUP) process and child processes
|
|
100
143
|
#
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
fi
|
|
144
|
+
for _ONE_PID in ${ALL_CHILD_PIDS}; do
|
|
145
|
+
kill -HUP "${_ONE_PID}" >/dev/null 2>&1
|
|
146
|
+
done
|
|
105
147
|
sleep 1
|
|
106
148
|
|
|
107
149
|
#
|
|
108
|
-
#
|
|
150
|
+
# If processes are running yet, try to kill it.
|
|
109
151
|
#
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
#
|
|
114
|
-
if ! /bin/sh -c "kill -KILL ${OLD_PID} ${OLD_CIHLD_PIDS}" >/dev/null 2>&1; then
|
|
115
|
-
echo "[WARNING] Failed to retry stop some old processes."
|
|
152
|
+
for _ONE_PID in ${ALL_CHILD_PIDS}; do
|
|
153
|
+
if ps -p "${_ONE_PID}" >/dev/null 2>&1; then
|
|
154
|
+
kill -KILL "${_ONE_PID}" >/dev/null 2>&1
|
|
116
155
|
fi
|
|
117
|
-
|
|
156
|
+
done
|
|
157
|
+
sleep 1
|
|
118
158
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
159
|
+
#
|
|
160
|
+
# Result
|
|
161
|
+
#
|
|
162
|
+
for _ONE_PID in ${ALL_CHILD_PIDS}; do
|
|
163
|
+
if ps -p "${_ONE_PID}" >/dev/null 2>&1; then
|
|
123
164
|
echo "[ERROR] Could not stop old processes."
|
|
124
165
|
return 1
|
|
125
166
|
fi
|
|
126
|
-
|
|
167
|
+
done
|
|
168
|
+
|
|
127
169
|
echo "[INFO] Stop old processes."
|
|
128
170
|
fi
|
|
129
171
|
rm -f "${PROC_PID_FILE}"
|