使用 systemd 后台值守运行 Bark
source link: https://www.ixiqin.com/2021/09/using-systemd-background-unattended-operation-bark/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
使用 systemd 后台值守运行 Bark
什么是 Bark?
Bark 是由 Fin 开源的一个向 iOS 设备推送通知的服务,Bark 支持自行部署服务端,从而实现消息的推送通过自己的服务器进行,避免与官方的服务共享,提升推送时效。
服务端源码:Finb/bark-server: Backend of Bark (github.com)
Bark 如何部署?
Bark 的部署非常简单,直接下载官方的 release 文件即可。
下载完成后,你可以执行如下命令来进行测试
bark-server -addr 0.0.0.0:8080 -data ./bark-data
执行成功后,你会看到如下的界面,此时你可以访问 127.0.0.1/ping
来验证你的 Bark 的部署
使用 Systemd 进行值守
验证成功后,接下来就可以设定值守运行了
1. 将 bark server 移动到一个固定目录
首先,你需要将 bark server 移动到一个固定的目录,方便后续执行。
mv bark-server /usr/local/sbin/bark-server
2. 创建 Bark Service
创建 /etc/systemd/system/bark.service
文件,并添加如下内容
[Unit]
Description=Bark Server
[Service]
ExecStart=/usr/local/sbin/bark-server -addr 0.0.0.0:8080 -data /usr/local/bark-data
[Install]
WantedBy=multi-user.target
创建完成后,你可以执行 systemctl status bark
来查看 bark server 的状态。
然后,你就可以使用 systemctl
来控制bark 了
- 启动服务
systemctl start bark
- 停止服务
systemctl stop bark
- 查看服务状态
systemctl status bark
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK