美文网首页
设置开机自动运行 live-server

设置开机自动运行 live-server

作者: tzktzk1 | 来源:发表于2025-01-22 02:48 被阅读0次

1查看本机live-server安装目录

root@tzktzk1-Lenovo-Gaming:/media# which live-server
/usr/local/bin/live-server
root@tzktzk1-Lenovo-Gaming:/media# node -v
v20.9.0
root@tzktzk1-Lenovo-Gaming:/media# npm -v
10.7.0

2.创建服务文件

sudo nano /etc/systemd/system/live-server-other.service

内容为:

[Unit]
Description=Live Server for /media/other

[Service]
ExecStart=/usr/local/bin/live-server /media/other --port=5500
WorkingDirectory=/media/other
Restart=always
User=tzktzk1
Environment=NODE_ENV=production

[Install]
WantedBy=multi-user.target

tzktzk1为登录用户的用户名

3.重新加载系统服务、启动服务

sudo systemctl daemon-reload
sudo systemctl start live-server-other

4.设置开机自启

sudo systemctl enable live-server-other

5.检查服务状态

sudo systemctl status live-server-other

6.如果遇到问题,可以查看服务的日志以获取更多信息:

journalctl -u live-server-other.service

相关文章

网友评论

      本文标题:设置开机自动运行 live-server

      本文链接:https://www.haomeiwen.com/subject/tpgqujtx.html