Skip to content

Commit 0dc93e4

Browse files
committed
添加守护进程管理命令,包括启动、停止、重启、状态查看和日志跟踪功能。更新.gitignore以排除新的日志文件。新增Makefile以支持多平台构建。
1 parent b392085 commit 0dc93e4

File tree

4 files changed

+418
-12
lines changed

4 files changed

+418
-12
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ cert-deploy
3636
certs
3737
ssl
3838
install.sh
39-
Makefile
40-
config.yaml
39+
config.yaml
40+
cert-deploy.log

Makefile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
.PHONY: build build-mac build-linux build-windows compress build-compress proto clean install
2+
3+
# 默认目标
4+
all: proto build
5+
6+
# 构建二进制文件
7+
build: build-mac build-linux build-windows
8+
@echo "所有平台构建完成"
9+
10+
# 构建 Mac 版本
11+
build-mac:
12+
@echo "构建 Mac 版本..."
13+
@mkdir -p bin
14+
@GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o bin/cert-deploy-mac main.go
15+
@GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -trimpath -o bin/cert-deploy-mac-arm64 main.go
16+
@echo "Mac 版本构建完成"
17+
18+
# 构建 Linux 版本
19+
build-linux:
20+
@echo "构建 Linux 版本..."
21+
@mkdir -p bin
22+
@GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o bin/cert-deploy-linux main.go
23+
@GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -trimpath -o bin/cert-deploy-linux-arm64 main.go
24+
@echo "Linux 版本构建完成"
25+
26+
# 构建 Windows 版本
27+
build-windows:
28+
@echo "构建 Windows 版本..."
29+
@mkdir -p bin
30+
@GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o bin/cert-deploy-windows.exe main.go
31+
@GOOS=windows GOARCH=arm64 go build -ldflags="-s -w" -trimpath -o bin/cert-deploy-windows-arm64.exe main.go
32+
@echo "Windows 版本构建完成"
33+
34+
# 压缩二进制文件(需要安装 UPX)
35+
compress:
36+
@echo "压缩二进制文件..."
37+
@if command -v upx >/dev/null 2>&1; then \
38+
upx --best bin/cert-deploy-linux*; \
39+
echo "压缩完成"; \
40+
else \
41+
echo "UPX 未安装,跳过压缩步骤"; \
42+
echo "安装 UPX: brew install upx (macOS) 或 apt install upx (Ubuntu)"; \
43+
fi
44+
45+
# 构建并压缩所有版本
46+
build-compress: build compress
47+
@echo "构建和压缩完成"

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77
创建配置文件 `config.yaml`:
88

99
```yaml
10-
# 证书部署配置
1110
server:
11+
# 在 设置-->个人资料 中找到
1212
accessKey: ""
1313

14-
# 证书存储配置
1514
ssl:
16-
# 证书存储根目录
15+
# 证书存储根目录,不配置默认放在【与程序同级目录/certs】
1716
path: "/etc/nginx/ssl"
1817
```
1918
@@ -22,11 +21,14 @@ ssl:
2221
### 基本命令
2322
2423
```bash
25-
# 显示帮助信息
26-
cert-deploy --help
27-
28-
# 启动守护进程模式
29-
cert-deploy daemon
24+
./cert-deploy --help # 显示帮助信息
25+
26+
./cert-deploy daemon # 启动守护进程(后台运行)
27+
./cert-deploy log # 查看守护进程日志,-f 实时跟踪日志输出
28+
./cert-deploy restart # 重启守护进程
29+
./cert-deploy start # 启动守护进程(前台运行)
30+
./cert-deploy status # 查看守护进程状态
31+
./cert-deploy stop # 停止守护进程
3032
```
3133

3234
## 许可证

0 commit comments

Comments
 (0)