@@ -33,7 +33,7 @@ usage() {
3333 无参数:gum 菜单(status / install / help / quit)。
3434
3535命令:
36- status [--no-http] 以表格汇总 Airflow、Celery、Paperclip、code-server、new-api(PID、端口、可选 HTTP 探测 )
36+ status [--no-http] 汇总 Airflow、Celery、Paperclip、code-server、new-api(有 gum 时用 gum table -p;否则 column )
3737 install 无参:gum 先选「安装 / 卸载」,再选模块。
3838 install add <模块> 安装(add 可写 install)
3939 install remove <模块> 卸载(remove 可写 uninstall;celery/utils 不支持)
@@ -106,10 +106,9 @@ _status_tsv_line() {
106106 printf ' %s\t%s\t%s\t%s\t%s\n' " $1 " " $2 " " $3 " " $4 " " $5 "
107107}
108108
109- # stdin 为 CSV → gum table -p;无 gum 时勿调用本函数,应改送 TSV 给 column
109+ # stdin 为数据行 CSV(无表头;列名由 --columns 指定) → gum table 静态打印
110110_render_status_table_from_csv () {
111111 PATH=" ${HOME} /opt/gum/bin:${PATH} "
112- command -v gum > /dev/null 2>&1 || return 1
113112 gum table -p -s ' ,' \
114113 --columns ' 服务,状态,PID,端口/访问,HTTP' \
115114 --border rounded
@@ -183,42 +182,79 @@ cmd_status() {
183182 cel_wbf=" $( _mark_alive " $pid_cel_w " ) $( _mark_alive " $pid_cel_b " ) $( _mark_alive " $pid_cel_f " ) "
184183 cel_pids=" ${pid_cel_w:- -} /${pid_cel_b:- -} /${pid_cel_f:- -} "
185184
186- echo " nltdeploy 服务概览(表格) ${ts} "
185+ echo " nltdeploy 服务概览 ${ts} "
187186 echo " "
188187
189- {
190- _status_row " 服务" " 状态" " PID" " 端口/访问" " HTTP"
191- _status_row \
192- " airflow" \
193- " $( status_word " $airflow_pid " ) " \
194- " ${airflow_pid:- -} " \
195- " ${AIRFLOW_PORT} → 127.0.0.1:${AIRFLOW_PORT} " \
196- " $( http_probe " http://127.0.0.1:${AIRFLOW_PORT} /" ) "
197- _status_row \
198- " celery" \
199- " wbf ${cel_wbf} " \
200- " ${cel_pids} " \
201- " flower ${FLOWER_PORT} (${FLOWER_ADDRESS} )" \
202- " ${cel_probe} "
203- _status_row \
204- " paperclip" \
205- " $( status_word " $pid_pc " ) " \
206- " ${pid_pc:- -} " \
207- " ${PAPERCLIP_PORT} /api/health" \
208- " $( http_probe " http://127.0.0.1:${PAPERCLIP_PORT} /api/health" ) "
209- _status_row \
210- " code-server" \
211- " $( status_word " $pid_cs " ) " \
212- " ${pid_cs:- -} " \
213- " ${CODE_SERVER_BIND} " \
214- " $( http_probe " http://127.0.0.1:${CODE_SERVER_PORT} /" ) "
215- _status_row \
216- " new-api" \
217- " $( status_word " $pid_na " ) " \
218- " ${pid_na:- -} " \
219- " ${NEW_API_PORT} → 127.0.0.1:${NEW_API_PORT} " \
220- " $( http_probe " http://127.0.0.1:${NEW_API_PORT} /" ) "
221- } | _print_table
188+ PATH=" ${HOME} /opt/gum/bin:${PATH} "
189+ if command -v gum > /dev/null 2>&1 ; then
190+ {
191+ _status_csv_line \
192+ " airflow" \
193+ " $( status_word " $airflow_pid " ) " \
194+ " ${airflow_pid:- -} " \
195+ " ${AIRFLOW_PORT} → 127.0.0.1:${AIRFLOW_PORT} " \
196+ " $( http_probe " http://127.0.0.1:${AIRFLOW_PORT} /" ) "
197+ _status_csv_line \
198+ " celery" \
199+ " wbf ${cel_wbf} " \
200+ " ${cel_pids} " \
201+ " flower ${FLOWER_PORT} (${FLOWER_ADDRESS} )" \
202+ " ${cel_probe} "
203+ _status_csv_line \
204+ " paperclip" \
205+ " $( status_word " $pid_pc " ) " \
206+ " ${pid_pc:- -} " \
207+ " ${PAPERCLIP_PORT} /api/health" \
208+ " $( http_probe " http://127.0.0.1:${PAPERCLIP_PORT} /api/health" ) "
209+ _status_csv_line \
210+ " code-server" \
211+ " $( status_word " $pid_cs " ) " \
212+ " ${pid_cs:- -} " \
213+ " ${CODE_SERVER_BIND} " \
214+ " $( http_probe " http://127.0.0.1:${CODE_SERVER_PORT} /" ) "
215+ _status_csv_line \
216+ " new-api" \
217+ " $( status_word " $pid_na " ) " \
218+ " ${pid_na:- -} " \
219+ " ${NEW_API_PORT} → 127.0.0.1:${NEW_API_PORT} " \
220+ " $( http_probe " http://127.0.0.1:${NEW_API_PORT} /" ) "
221+ } | _render_status_table_from_csv
222+ else
223+ echo " (未检测到 gum,使用 column 对齐;安装 gum 见 nlt-utils 或 ~/opt/gum/bin)" >&2
224+ {
225+ _status_tsv_line " 服务" " 状态" " PID" " 端口/访问" " HTTP"
226+ _status_tsv_line \
227+ " airflow" \
228+ " $( status_word " $airflow_pid " ) " \
229+ " ${airflow_pid:- -} " \
230+ " ${AIRFLOW_PORT} → 127.0.0.1:${AIRFLOW_PORT} " \
231+ " $( http_probe " http://127.0.0.1:${AIRFLOW_PORT} /" ) "
232+ _status_tsv_line \
233+ " celery" \
234+ " wbf ${cel_wbf} " \
235+ " ${cel_pids} " \
236+ " flower ${FLOWER_PORT} (${FLOWER_ADDRESS} )" \
237+ " ${cel_probe} "
238+ _status_tsv_line \
239+ " paperclip" \
240+ " $( status_word " $pid_pc " ) " \
241+ " ${pid_pc:- -} " \
242+ " ${PAPERCLIP_PORT} /api/health" \
243+ " $( http_probe " http://127.0.0.1:${PAPERCLIP_PORT} /api/health" ) "
244+ _status_tsv_line \
245+ " code-server" \
246+ " $( status_word " $pid_cs " ) " \
247+ " ${pid_cs:- -} " \
248+ " ${CODE_SERVER_BIND} " \
249+ " $( http_probe " http://127.0.0.1:${CODE_SERVER_PORT} /" ) "
250+ _status_tsv_line \
251+ " new-api" \
252+ " $( status_word " $pid_na " ) " \
253+ " ${pid_na:- -} " \
254+ " ${NEW_API_PORT} → 127.0.0.1:${NEW_API_PORT} " \
255+ " $( http_probe " http://127.0.0.1:${NEW_API_PORT} /" ) "
256+ } | _print_status_rows_column
257+ fi
222258
223259 echo " "
224260 echo " 说明:"
0 commit comments