编写 Systemd Unit 服务文件
简单示例:
[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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论