Skip to content

Instantly share code, notes, and snippets.

@jiahut
Created July 8, 2025 11:15
Show Gist options
  • Save jiahut/bd188e5103f973519451716088521d88 to your computer and use it in GitHub Desktop.
Save jiahut/bd188e5103f973519451716088521d88 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -euo pipefail
# markservman: 管理 markserv 服务的工具
# Usage: markservman {install|start|stop|status|logs}
action=${1:-}
case "$action" in
install)
echo "Installing markserv globally using bun..."
bun install -g markserv
;;
start)
echo "Starting markserv service via systemd user unit..."
systemd-run --user --unit=markserv \
--working-directory="$(pwd)" \
--property=StandardOutput=journal \
--property=StandardError=journal \
--setenv=PATH="$HOME/.bun/bin:$PATH" \
markserv -p 8080 -a 0.0.0.0
;;
stop)
echo "Stopping markserv service..."
systemctl --user stop markserv.service
;;
status)
echo "Displaying status of markserv service..."
systemctl --user status markserv.service
;;
logs)
echo "Tailing logs for markserv service..."
journalctl --user -u markserv -n50 -f
;;
*)
echo "Usage: $0 {install|start|stop|status|logs}" >&2
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment