# 运行本地开发环境(使用SSH隧道代理端口) dev: @if ! go list -m github.com/gravityblast/fresh >/dev/null 2>&1; then \ echo "github.com/gravityblast/fresh is not installed. Installing..."; \ go get github.com/gravityblast/fresh; \ fi; @ssh -NCPf main -L 3306:localhost:3306 -L 19530:localhost:19530 & \ sleep 1; \ echo "Starting Go application..."; \ go run github.com/gravityblast/fresh; \ wait # 编译项目 build: go mod tidy go build -o dist/main bin/main.go # 更新部署到服务器 update: build host="root@main" ssh $host "mv ~/webp/main ~/webp/main_old" scp dist/main $host:~/webp/main rm -rf dist ssh $host "systemctl restart webp" ssh $host "rm ~/webp/main_old" # 设为系统服务和日志轮转 service: sudo cp webp.service /etc/systemd/system/webp.service sudo systemctl enable webp sudo cp webp.logrotate /etc/logrotate.d/webp