auto-save 2026-05-15 11:29 (+1, ~3)

This commit is contained in:
2026-05-15 11:29:23 +08:00
parent e6b2768482
commit 55a9a9d936
5 changed files with 83 additions and 26 deletions

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.skg.tk-recreate.api.dev</string>
<key>ProgramArguments</key>
<array>
<string>/bin/zsh</string>
<string>-lc</string>
<string>cd /Users/kangwan/Projects/business/20260512-20260512-skg-tk-二创验证/api &amp;&amp; source .venv/bin/activate &amp;&amp; exec .venv/bin/uvicorn main:app --host 127.0.0.1 --port 4291</string>
</array>
<key>WorkingDirectory</key>
<string>/Users/kangwan/Projects/business/20260512-20260512-skg-tk-二创验证/api</string>
<key>StandardOutPath</key>
<string>/Users/kangwan/Projects/business/20260512-20260512-skg-tk-二创验证/.logs/api.launchd.log</string>
<key>StandardErrorPath</key>
<string>/Users/kangwan/Projects/business/20260512-20260512-skg-tk-二创验证/.logs/api.launchd.err.log</string>
<key>RunAtLoad</key>
<false/>
<key>KeepAlive</key>
<false/>
</dict>
</plist>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.skg.tk-recreate.web.dev</string>
<key>ProgramArguments</key>
<array>
<string>/bin/zsh</string>
<string>-lc</string>
<string>cd /Users/kangwan/Projects/business/20260512-20260512-skg-tk-二创验证/web &amp;&amp; exec pnpm dev</string>
</array>
<key>WorkingDirectory</key>
<string>/Users/kangwan/Projects/business/20260512-20260512-skg-tk-二创验证/web</string>
<key>StandardOutPath</key>
<string>/Users/kangwan/Projects/business/20260512-20260512-skg-tk-二创验证/.logs/web.launchd.log</string>
<key>StandardErrorPath</key>
<string>/Users/kangwan/Projects/business/20260512-20260512-skg-tk-二创验证/.logs/web.launchd.err.log</string>
<key>RunAtLoad</key>
<false/>
<key>KeepAlive</key>
<false/>
</dict>
</plist>

View File

@@ -6,6 +6,10 @@ API_DIR="$ROOT_DIR/api"
WEB_DIR="$ROOT_DIR/web"
LOG_DIR="$ROOT_DIR/.logs"
PID_DIR="$ROOT_DIR/.pids"
LAUNCHD_DIR="$ROOT_DIR/scripts/launchd"
LAUNCHD_DOMAIN="gui/$(id -u)"
API_LABEL="com.skg.tk-recreate.api.dev"
WEB_LABEL="com.skg.tk-recreate.web.dev"
mkdir -p "$LOG_DIR" "$PID_DIR"
@@ -23,12 +27,9 @@ start_api() {
echo "missing api/.venv/bin/uvicorn" >&2
exit 1
fi
(
cd "$API_DIR"
nohup .venv/bin/uvicorn main:app --host 127.0.0.1 --port 4291 >> "$LOG_DIR/api.log" 2>&1 &
echo $! > "$PID_DIR/api.pid"
)
echo "api started on 4291, log: $LOG_DIR/api.log"
launchctl bootout "$LAUNCHD_DOMAIN" "$API_LABEL" >/dev/null 2>&1 || true
launchctl bootstrap "$LAUNCHD_DOMAIN" "$LAUNCHD_DIR/$API_LABEL.plist"
echo "api started on 4291 via launchd, log: $LOG_DIR/api.launchd.log"
}
start_web() {
@@ -40,12 +41,9 @@ start_web() {
echo "missing pnpm in PATH" >&2
exit 1
fi
(
cd "$WEB_DIR"
nohup pnpm dev >> "$LOG_DIR/web.log" 2>&1 &
echo $! > "$PID_DIR/web.pid"
)
echo "web started on 4290, log: $LOG_DIR/web.log"
launchctl bootout "$LAUNCHD_DOMAIN" "$WEB_LABEL" >/dev/null 2>&1 || true
launchctl bootstrap "$LAUNCHD_DOMAIN" "$LAUNCHD_DIR/$WEB_LABEL.plist"
echo "web started on 4290 via launchd, log: $LOG_DIR/web.launchd.log"
}
start_api

View File

@@ -3,6 +3,16 @@ set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
PID_DIR="$ROOT_DIR/.pids"
LAUNCHD_DOMAIN="gui/$(id -u)"
stop_launchd_label() {
local label="$1"
if launchctl bootout "$LAUNCHD_DOMAIN" "$label" >/dev/null 2>&1; then
echo "$label stopped"
else
echo "$label not loaded"
fi
}
stop_pid_file() {
local name="$1"
@@ -24,3 +34,5 @@ stop_pid_file() {
stop_pid_file api
stop_pid_file web
stop_launchd_label com.skg.tk-recreate.api.dev
stop_launchd_label com.skg.tk-recreate.web.dev