Linux 创建服务
2023-02-07 本文已影响0人
承诺一时的华丽
配置 Systemd (Linux)
- 为日志文件和缓存文件创建目录。
sudo mkdir -p /etc/gorse/
sudo mkdir -p /var/log/gorse/
sudo mkdir -p /var/lib/gorse/
- 将配置文件复制到/etc/gorse :
sudo mv config.toml /etc/gorse/
- 在/etc/systemd/system/gorse.service创建 systemd 配置文件:
[Unit]
Description=Gorse, an open source recommender system service written in Go.
After=network.target
[Service]
Type=simple
Restart=always
ExecStart=/usr/local/bin/gorse-in-one -c /etc/gorse/config.toml \
--log-path /var/log/gorse/gorse.log \
--cache-path /var/lib/gorse/gorse.data
[Install]
WantedBy=multi-user.target
- 然后重新加载systemd:
sudo systemctl daemon-reload
- 在系统启动的同时启动 gorse-in-one:
sudo systemctl enable gorse
- 立即启动 gorse-in-one:
sudo systemctl start gorse
- 检查 gorse-in-one 的运行状态和日志:
systemctl status gorse