create-entity-server 0.9.16 → 0.9.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-entity-server",
3
- "version": "0.9.16",
3
+ "version": "0.9.17",
4
4
  "description": "Create a new entity-server project in one command — like create-react-app or create-vite.",
5
5
  "keywords": [
6
6
  "entity-server",
@@ -799,7 +799,11 @@ if [ ! -f "$DATABASE_CONFIG" ]; then
799
799
  exit 1
800
800
  fi
801
801
 
802
- if [ ! -f "$SERVER_BIN" ]; then
802
+ # stop 바이너리가 없어도 동작해야 한다(포트/PID 기준으로 종료하므로).
803
+ # update-server.sh 가 업데이트 중 바이너리를 지운 상태에서 run.sh stop 을 호출하는
804
+ # 경우가 있어, 여기서 막으면 "바이너리 없음 → stop 실패 → 종료 못 함" 악순환이 된다.
805
+ # 나머지 모드(dev/start/restart/status)는 바이너리가 반드시 필요하다.
806
+ if [ "$MODE" != "stop" ] && [ ! -f "$SERVER_BIN" ]; then
803
807
  if [ "$LANGUAGE" = "en" ]; then
804
808
  echo "❌ entity-server binary not found (bin/entity-server or ./entity-server)"
805
809
  echo " Run ./scripts/update-server.sh to download the latest binary."
@@ -32,9 +32,43 @@ _find_running_pid() {
32
32
  pgrep -f "${PROJECT_ROOT}/(bin/)?entity-server( |$)" | head -n 1
33
33
  }
34
34
 
35
+ _list_running_pids() {
36
+ local pid_file="$PROJECT_ROOT/.run/entity-server.pid"
37
+
38
+ {
39
+ if [ -f "$pid_file" ]; then
40
+ local pid
41
+ pid=$(cat "$pid_file" 2>/dev/null)
42
+ if [ -n "$pid" ] && kill -0 "$pid" 2>/dev/null; then
43
+ echo "$pid"
44
+ fi
45
+ fi
46
+
47
+ pgrep -f "${PROJECT_ROOT}/(bin/)?entity-server( |$)" 2>/dev/null || true
48
+ } | awk 'NF { print }' | sort -u
49
+ }
50
+
51
+ _kill_pid() {
52
+ local pid="$1"
53
+
54
+ [ -n "$pid" ] || return 0
55
+
56
+ kill "$pid" 2>/dev/null || sudo -n kill "$pid" 2>/dev/null || true
57
+
58
+ for _ in $(seq 1 10); do
59
+ if ! kill -0 "$pid" 2>/dev/null; then
60
+ return 0
61
+ fi
62
+ sleep 0.1
63
+ done
64
+
65
+ kill -9 "$pid" 2>/dev/null || sudo -n kill -9 "$pid" 2>/dev/null || true
66
+ }
67
+
35
68
  _ensure_server_stopped() {
36
- local pid
37
- pid="$(_find_running_pid)"
69
+ local pid pids
70
+ pids="$(_list_running_pids)"
71
+ pid=$(echo "$pids" | head -n 1)
38
72
 
39
73
  if [ -z "$pid" ]; then
40
74
  return 0
@@ -55,7 +89,17 @@ _ensure_server_stopped() {
55
89
  if [ -x "$PROJECT_ROOT/scripts/run.sh" ]; then
56
90
  "$PROJECT_ROOT/scripts/run.sh" stop || true
57
91
  else
58
- kill "$pid" 2>/dev/null || true
92
+ _kill_pid "$pid"
93
+ fi
94
+
95
+ pids="$(_list_running_pids)"
96
+ if [ -n "$pids" ]; then
97
+ while read -r pid; do
98
+ [ -n "$pid" ] || continue
99
+ _kill_pid "$pid"
100
+ done <<EOF
101
+ $pids
102
+ EOF
59
103
  fi
60
104
 
61
105
  sleep 0.2