|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# XXX: Either add a trailing slash wherever this variable is used |
| 4 | +# (to increase flexibility), or |
| 5 | +# ensure that this variable always has a trailing slash. |
| 6 | +LOG_DIR="/var/log/uwuStore" |
| 7 | + |
| 8 | +# For developers |
| 9 | +# LOG_DIR="./log/store" |
| 10 | + |
| 11 | +TIMESTAMP="$(date +%Y-%m-%dT%H-%M-%S)" |
| 12 | + |
| 13 | +# XXX: We should run with WSGI server |
| 14 | +START_COMMAND="uv run flask run" |
| 15 | + |
| 16 | +# Simulate Ctrl-C (SIGINT) instead of SIGKILL to exit as safely as possible |
| 17 | +screen -S store -X stuff "\003" |
| 18 | + |
| 19 | +mkdir -p "${LOG_DIR}" || exit 1 |
| 20 | +test -w "${LOG_DIR}" || { \ |
| 21 | + echo "Please make sure you have permission to write log file to ${LOG_DIR}"; \ |
| 22 | + exit 1 |
| 23 | +} |
| 24 | + |
| 25 | +echo "Log file will be written to ${LOG_DIR}/Log_${TIMESTAMP}.log" |
| 26 | +echo "HINT: If you see [screen is terminating], the process have exited" |
| 27 | +echo "HINT: 如果你看見 [screen is terminating], 那麼很遺憾的這個處理程序並未正常啟動" |
| 28 | + |
| 29 | +# Start a process with screen |
| 30 | +# To avoid someone who didn't know how to detach the screen |
| 31 | +screen -S store -L -Logfile "${LOG_DIR}/Log_${TIMESTAMP}.log" \ |
| 32 | + bash -c "echo TIPS: You can detach with Ctrl-A D; |
| 33 | + echo which won\'t kill the process; |
| 34 | + echo and you can reattach to observer the output and interact with util-store-reattach.sh; \ |
| 35 | + echo 您可以透過 Ctrl-A D 脫離這個界面,並且不會殺死這個處理程序; |
| 36 | + echo 之後也可以透過 util-store-reattach.sh 重新回來觀察輸出與互動; |
| 37 | + ${START_COMMAND}" |
0 commit comments