为了方便管理 hexo 的启停,特意在 /lib/systemd/system/ 目录下创建一个 hexo 的启动脚本文件 hexo.service, 内容为:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[Unit]
Description=Hexo Blog Service
After=network.target

[Service]
Type=simple
#User=gitlab-runner
#Group=gitlab-runner
Environment=PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/nodejs/bin
WorkingDirectory=/data/hexo/blog
ExecStart=/usr/local/nodejs/lib/node_modules/hexo-cli/bin/hexo server -p 80
ExecReload=/bin/kill -HUP $MAINPID
#ExecReload=/bin/kill -SIGINT $MAINPID
#ExecReload=/usr/local/nodejs/lib/node_modules/hexo-cli/bin/hexo server -p 80
ExecStop=/bin/kill -SIGINT $MAINPID
Restart=always

[Install]
WantedBy=multi-user.target