Skip to content

Commit dd02592

Browse files
committed
chore: Sync sh scripts from branch "deployed"
1 parent 0c86604 commit dd02592

6 files changed

Lines changed: 83 additions & 0 deletions

File tree

util-bot-reattach.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
screen -r bot

util-bot-restart.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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/Bot_uwu"
7+
8+
# For developers
9+
# LOG_DIR="./log/bot"
10+
11+
TIMESTAMP="$(date +%Y-%m-%dT%H-%M-%S)"
12+
13+
START_COMMAND="uv run ./main.py"
14+
15+
# Simulate Ctrl-C (SIGINT) instead of SIGKILL to exit as safely as possible
16+
screen -S bot -X stuff "\003"
17+
18+
mkdir -p "${LOG_DIR}" || exit 1
19+
test -w "${LOG_DIR}" || { \
20+
echo "Please make sure you have permission to write log file to ${LOG_DIR}"; \
21+
exit 1
22+
}
23+
24+
echo "Log file will be written to ${LOG_DIR}/Log_${TIMESTAMP}.log"
25+
echo "HINT: If you see [screen is terminating], the process have exited"
26+
echo "HINT: 如果你看見 [screen is terminating], 那麼很遺憾的這個處理程序並未正常啟動"
27+
28+
# Start a process with screen
29+
# To avoid someone who didn't know how to detach the screen
30+
screen -S bot -L -Logfile "${LOG_DIR}/Log_${TIMESTAMP}.log" \
31+
bash -c "echo TIPS: You can detach with Ctrl-A D;
32+
echo which won\'t kill the process;
33+
echo and you can reattach to observer the output and interact with util-bot-reattach.sh; \
34+
echo TIPS: 您可以透過 Ctrl-A D 脫離這個界面,並且不會殺死這個處理程序;
35+
echo 之後也可以透過 util-bot-reattach.sh 重新回來觀察輸出與互動;
36+
${START_COMMAND}"

util-bot-stop.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
screen -S bot -X stuff "\003"

util-store-reattach.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
screen -r store

util-store-restart.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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}"

util-store-stop.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
screen -S store -X stuff "\003"

0 commit comments

Comments
 (0)