编写 Systemd Unit 服务文件

发布于 2023-12-02 06:48:40 字数 1203 浏览 25 评论 0

简单示例:

[Unit]
Description=a node.js micro framework.
After=dbus.service
After=polkit.service

[Service]
Type=notify
ExecStart=/usr/bin/node /home/vagrant/koapp/index.js

[Install]
WantedBy=multi-user.target
Alias=koa.service

具体参数配置参考: https://wiki.archlinux.org/index.php/Systemd_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)

PHP-fpm 示例:

[Unit]
Description=The PHP 7.2 FastCGI Process Manager
Documentation=man:php-fpm7.2(8)
After=network.target

[Service]
Type=notify
PIDFile=/run/php/php7.2-fpm.pid
ExecStart=/usr/sbin/php-fpm7.2 --nodaemonize --fpm-config /etc/php/7.2/fpm/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID

[Install]
WantedBy=multi-user.target

Gunicorn 示例:

[Unit]
Description=a flask application run on gunicorn.
After=network.target

[Service]
PIDFile=/run/gunicorn/pid
WorkingDirectory=/home/vagrant/pyapp
ExecStart=/home/vagrant/miniconda/bin/gunicorn -w 4 -b 0.0.0.0:8080 application:app
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

关于作者

林空鹿饮溪

暂无简介

文章
评论
27 人气
更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文