create-entity-server 0.4.1 → 0.4.3
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 +1 -1
- package/template/scripts/run.sh +46 -11
package/package.json
CHANGED
package/template/scripts/run.sh
CHANGED
|
@@ -258,8 +258,14 @@ stop_pid_with_confirm() {
|
|
|
258
258
|
|
|
259
259
|
stop_server() {
|
|
260
260
|
if [ ! -f "$PID_FILE" ]; then
|
|
261
|
+
local port_pid
|
|
262
|
+
port_pid=$(find_pid_by_port)
|
|
263
|
+
if [ -n "$port_pid" ] && kill -0 "$port_pid" 2>/dev/null; then
|
|
264
|
+
stop_pid_with_confirm "$port_pid" "port"
|
|
265
|
+
return $?
|
|
266
|
+
fi
|
|
261
267
|
if is_port_in_use; then
|
|
262
|
-
|
|
268
|
+
show_port_in_use_message
|
|
263
269
|
return 0
|
|
264
270
|
fi
|
|
265
271
|
if [ "$LANGUAGE" = "en" ]; then
|
|
@@ -274,8 +280,14 @@ stop_server() {
|
|
|
274
280
|
pid=$(cat "$PID_FILE" 2>/dev/null)
|
|
275
281
|
if [ -z "$pid" ]; then
|
|
276
282
|
rm -f "$PID_FILE"
|
|
283
|
+
local port_pid
|
|
284
|
+
port_pid=$(find_pid_by_port)
|
|
285
|
+
if [ -n "$port_pid" ] && kill -0 "$port_pid" 2>/dev/null; then
|
|
286
|
+
stop_pid_with_confirm "$port_pid" "port"
|
|
287
|
+
return $?
|
|
288
|
+
fi
|
|
277
289
|
if is_port_in_use; then
|
|
278
|
-
|
|
290
|
+
show_port_in_use_message
|
|
279
291
|
return 0
|
|
280
292
|
fi
|
|
281
293
|
if [ "$LANGUAGE" = "en" ]; then
|
|
@@ -288,14 +300,24 @@ stop_server() {
|
|
|
288
300
|
|
|
289
301
|
if ! kill -0 "$pid" 2>/dev/null; then
|
|
290
302
|
rm -f "$PID_FILE"
|
|
303
|
+
local port_pid
|
|
304
|
+
port_pid=$(find_pid_by_port)
|
|
305
|
+
if [ -n "$port_pid" ] && kill -0 "$port_pid" 2>/dev/null; then
|
|
306
|
+
stop_pid_with_confirm "$port_pid" "port"
|
|
307
|
+
return $?
|
|
308
|
+
fi
|
|
291
309
|
if is_port_in_use; then
|
|
292
|
-
|
|
310
|
+
show_port_in_use_message
|
|
293
311
|
return 0
|
|
294
312
|
fi
|
|
295
313
|
if [ "$LANGUAGE" = "en" ]; then
|
|
296
|
-
echo "ℹ️
|
|
314
|
+
echo "ℹ️ Server process already exited (stale pid file removed)."
|
|
315
|
+
echo " Last log ($STDOUT_LOG):"
|
|
316
|
+
tail -5 "$STDOUT_LOG" 2>/dev/null | sed 's/^/ /'
|
|
297
317
|
else
|
|
298
|
-
echo "ℹ️
|
|
318
|
+
echo "ℹ️ 서버 프로세스가 이미 종료되어 있습니다 (stale pid 파일 정리됨)."
|
|
319
|
+
echo " 최근 로그 ($STDOUT_LOG):"
|
|
320
|
+
tail -5 "$STDOUT_LOG" 2>/dev/null | sed 's/^/ /'
|
|
299
321
|
fi
|
|
300
322
|
return 0
|
|
301
323
|
fi
|
|
@@ -422,7 +444,6 @@ fi
|
|
|
422
444
|
case "$MODE" in
|
|
423
445
|
dev|development)
|
|
424
446
|
if is_running; then
|
|
425
|
-
local running_pid
|
|
426
447
|
running_pid=$(find_pid_by_port)
|
|
427
448
|
if [ -n "$running_pid" ]; then
|
|
428
449
|
if [ "$LANGUAGE" = "en" ]; then
|
|
@@ -443,7 +464,6 @@ case "$MODE" in
|
|
|
443
464
|
|
|
444
465
|
start)
|
|
445
466
|
if is_running; then
|
|
446
|
-
local running_pid
|
|
447
467
|
running_pid=$(find_pid_by_port)
|
|
448
468
|
if [ -n "$running_pid" ]; then
|
|
449
469
|
if [ "$LANGUAGE" = "en" ]; then
|
|
@@ -462,11 +482,24 @@ case "$MODE" in
|
|
|
462
482
|
SERVER_PID=$!
|
|
463
483
|
echo "$SERVER_PID" > "$PID_FILE"
|
|
464
484
|
|
|
465
|
-
|
|
466
|
-
|
|
485
|
+
# 포트가 실제로 Listen 상태가 될 때까지 최대 5초 대기 (25 × 0.2s)
|
|
486
|
+
start_ok=0
|
|
487
|
+
for _ in $(seq 1 25); do
|
|
488
|
+
sleep 0.2
|
|
489
|
+
if ! kill -0 "$SERVER_PID" 2>/dev/null; then
|
|
490
|
+
break # 프로세스 사망
|
|
491
|
+
fi
|
|
492
|
+
if is_port_in_use; then
|
|
493
|
+
start_ok=1
|
|
494
|
+
break
|
|
495
|
+
fi
|
|
496
|
+
done
|
|
497
|
+
|
|
498
|
+
if [ "$start_ok" -eq 1 ]; then
|
|
467
499
|
if [ "$LANGUAGE" = "en" ]; then
|
|
468
500
|
echo "✅ Entity Server started in background (pid: $SERVER_PID)"
|
|
469
501
|
echo "Status: ./run.sh status"
|
|
502
|
+
echo "Stop: ./run.sh stop"
|
|
470
503
|
else
|
|
471
504
|
echo "✅ Entity Server가 백그라운드에서 시작되었습니다 (pid: $SERVER_PID)"
|
|
472
505
|
echo "상태: ./run.sh status"
|
|
@@ -476,10 +509,12 @@ case "$MODE" in
|
|
|
476
509
|
rm -f "$PID_FILE"
|
|
477
510
|
if [ "$LANGUAGE" = "en" ]; then
|
|
478
511
|
echo "❌ Failed to start Entity Server in background"
|
|
479
|
-
echo "
|
|
512
|
+
echo "Last log ($STDOUT_LOG):"
|
|
513
|
+
tail -20 "$STDOUT_LOG" 2>/dev/null | sed 's/^/ /'
|
|
480
514
|
else
|
|
481
515
|
echo "❌ Entity Server 백그라운드 시작에 실패했습니다"
|
|
482
|
-
echo "로그
|
|
516
|
+
echo "최근 로그 ($STDOUT_LOG):"
|
|
517
|
+
tail -20 "$STDOUT_LOG" 2>/dev/null | sed 's/^/ /'
|
|
483
518
|
fi
|
|
484
519
|
exit 1
|
|
485
520
|
fi
|