一、emqx開機自啟
a.首先在執行如下命令
vi /lib/systemd/system/emqx.service
創建了emqx.service文件然后在文件中寫入如下內容
[Unit]
Description=emqxautostart
After=network.target
[Service]
Type=forking
Environment=HOME=/opt/emqx
ExecStart=/opt/emqx/bin/emqx start
ExecReload=/opt/emqx/bin/emqx restart
ExecStop=/opt/emqx/bin/emqx stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
注意其中的
-
Environment=HOME=/opt/emqx
-
ExecStart=/opt/emqx/bin/emqx start
-
ExecReload=/opt/emqx/bin/emqx restart
-
ExecStop=/opt/emqx/bin/emqx stop
需要修改為自己的路徑
保存退出后我的的服務已經好了接下來可以使用
-
systemctl start emqx.service
-
systemctl stop emqx.service
進行啟動停止服務
我們還需要將服務添加到自啟動那么需要執行如下
systemctl enable emqx.service
reboot試一下,會發現開機能夠自啟動
二、nginx開機自啟
vim /lib/systemd/system/nginx.service
Description=nginx - high performance web server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/sbin/nginx -s reload
ExecStop=/usr/sbin/nginx -s stop
[Install]
WantedBy=multi-user.target
systemctl enable nginx.service
三、uwsgi開機自啟
vim /lib/systemd/system/summary.service
[Unit]
Description=uWSGI instance to serve summary
After=network.target
[Service]
User=lufficc
Group=www-data
WorkingDirectory=/your/path/summary
Environment=FLASKR_SETTINGS=/your/path/summary/env.cfg
ExecStart=/usr/local/bin/uwsgi --ini //your/path/summary/uwsgi.ini
[Install]
WantedBy=multi-user.target
systemctl enable summary.service