create-entity-server 0.5.6 → 0.7.0

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.5.6",
3
+ "version": "0.7.0",
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",
@@ -29,6 +29,24 @@ has_command() {
29
29
  command -v "$1" >/dev/null 2>&1
30
30
  }
31
31
 
32
+ # 현재 프로젝트를 관리하는 systemd 서비스명을 반환합니다.
33
+ find_systemd_service() {
34
+ local unit=""
35
+ local exec_start=""
36
+
37
+ has_command systemctl || return 1
38
+
39
+ for unit in $(systemctl list-units --type=service --state=active,activating --no-legend 2>/dev/null | awk '{print $1}'); do
40
+ exec_start=$(systemctl show -p ExecStart --value "$unit" 2>/dev/null || true)
41
+ if [[ "$exec_start" == *"$PROJECT_ROOT/scripts/run.sh"* ]] || [[ "$exec_start" == *"$SERVER_BIN"* ]]; then
42
+ echo "$unit"
43
+ return 0
44
+ fi
45
+ done
46
+
47
+ return 1
48
+ }
49
+
32
50
  # PID 프로세스명을 읽습니다.
33
51
  get_pid_name() {
34
52
  local pid="$1"
@@ -75,6 +93,31 @@ get_pid_cwd() {
75
93
  readlink -f "/proc/$pid/cwd" 2>/dev/null || true
76
94
  }
77
95
 
96
+ # 포트 점유 프로세스 상세 정보를 출력합니다.
97
+ print_port_process_details() {
98
+ local pid=""
99
+ local process_name=""
100
+ local cmdline=""
101
+
102
+ while read -r pid; do
103
+ pid=$(echo "$pid" | tr -d '[:space:]')
104
+ [ -z "$pid" ] && continue
105
+
106
+ process_name=$(get_pid_name "$pid")
107
+ cmdline=$(get_pid_cmdline "$pid")
108
+ [ -z "$process_name" ] && process_name="unknown"
109
+ [ -z "$cmdline" ] && cmdline="(command line unavailable)"
110
+
111
+ if [ "$LANGUAGE" = "en" ]; then
112
+ echo " PID: $pid | NAME: $process_name"
113
+ echo " CMD: $cmdline"
114
+ else
115
+ echo " PID: $pid | NAME: $process_name"
116
+ echo " CMD: $cmdline"
117
+ fi
118
+ done < <(find_server_pids)
119
+ }
120
+
78
121
  # PID가 실제 실행 중인지 Windows 폴백까지 포함해 확인합니다.
79
122
  is_pid_running() {
80
123
  local pid="$1"
@@ -360,6 +403,8 @@ show_start_port_in_use_message() {
360
403
  else
361
404
  echo "❌ 포트 $port 가 이미 사용 중입니다. 먼저 중지하세요: ./run.sh stop"
362
405
  fi
406
+
407
+ print_port_process_details
363
408
  }
364
409
 
365
410
  show_unmanaged_server_message() {
@@ -373,6 +418,8 @@ show_unmanaged_server_message() {
373
418
  echo "ℹ️ 포트 $port 를 사용하는 프로세스가 있지만, 현재 프로젝트의 pid 파일로 시작한 서버가 아닙니다."
374
419
  echo " 안전을 위해 run.sh stop 은 포트 일치만으로 프로세스를 종료하지 않습니다."
375
420
  fi
421
+
422
+ print_port_process_details
376
423
  }
377
424
 
378
425
  stop_pid_with_confirm() {
@@ -412,6 +459,16 @@ stop_pid_with_confirm() {
412
459
  }
413
460
 
414
461
  stop_server() {
462
+ local svc=""
463
+ svc=$(find_systemd_service || true)
464
+ if [ -n "$svc" ]; then
465
+ echo "ℹ️ systemd 서비스 중지: $svc"
466
+ sudo systemctl stop "$svc"
467
+ rm -f "$PID_FILE"
468
+ echo "✅ ${SERVER_NAME} 종료 완료 (systemd)"
469
+ return 0
470
+ fi
471
+
415
472
  local pid=""
416
473
 
417
474
  pid=$(find_active_server_pid)
@@ -437,6 +494,14 @@ stop_server() {
437
494
  }
438
495
 
439
496
  show_status() {
497
+ local svc=""
498
+ svc=$(find_systemd_service || true)
499
+ if [ -n "$svc" ]; then
500
+ echo "ℹ️ systemd 서비스로 관리 중: $svc"
501
+ sudo systemctl status "$svc" --no-pager 2>/dev/null || true
502
+ return
503
+ fi
504
+
440
505
  local status_pid=""
441
506
 
442
507
  status_pid=$(find_active_server_pid || true)
@@ -576,6 +641,21 @@ case "$MODE" in
576
641
  ;;
577
642
 
578
643
  start)
644
+ # systemd 서비스가 등록되어 있으면 systemctl 로 관리한다.
645
+ svc=$(find_systemd_service || true)
646
+ if [ -n "$svc" ]; then
647
+ svc_state=$(systemctl is-active "$svc" 2>/dev/null || true)
648
+ if [ "$svc_state" = "active" ]; then
649
+ echo "ℹ️ ${SERVER_NAME}가 systemd 서비스로 이미 실행 중입니다: $svc"
650
+ echo " 재시작: sudo systemctl restart $svc"
651
+ exit 0
652
+ fi
653
+ echo "ℹ️ systemd 서비스 시작: $svc"
654
+ sudo systemctl start "$svc"
655
+ echo "✅ ${SERVER_NAME} 시작 완료 (systemd)"
656
+ exit 0
657
+ fi
658
+
579
659
  running_pid=$(find_active_server_pid || true)
580
660
  if [ -n "$running_pid" ]; then
581
661
  if [ "$LANGUAGE" = "en" ]; then