sách gpt4 ai đã đi

service - Centos 7 - 来自/etc/systemd/system/san.service 的服务未使用 systemctl start san.service 运行

In lại 作者:行者123 更新时间:2023-12-04 19:36:29 27 4
mua khóa gpt4 Nike

我按照此链接的说明进行操作:https://www.thegeekdiary.com/centos-rhel-7-how-to-make-custom-script-to-run-automatically-during-boot/

但我有问题,因为我的服务没有运行。

我创建了一个脚本 startSanic2.sh 调用 startSanic.sh 脚本(我需要这个,因为当我用 & 手动启动它时,只有在这种情况下 session 没有过期)

这是我的脚本 startSanic2.sh

# cat /opt/horses/startSanic2.sh 
#!/thùng/bash
cd /opt/horses
./startSanic.sh &

这是我的脚本 startSanic.sh
# cat /opt/horses/startSanic.sh 
#!/thùng/bash
gunicorn horses.server:app --bind 0.0.0.0:9000 --worker-class sanic.worker.GunicornWorker --reload

运行后(./startSanic2.sh),它正在端口 9000 上成功运行。

startSanic.sh 和 startSanic2.sh 的权限为 755

然后我创建了新的 san.service
[root@testnn2 system]# cat /etc/systemd/system/san.service
[Unit]
Description=Description for sample script goes here
After=network.target

[Service]
Type=simple
ExecStart=/opt/horses/startSanic2.sh
TimeoutStartSec=0

[Install]
WantedBy=default.target

我运行这个命令:
systemctl daemon-reload

我运行这个命令
# systemctl enable san.service
Created symlink from /etc/systemd/system/default.target.wants/san.service to /etc/systemd/system/san.service

当我运行它时 - 没有任何 react :(
systemctl start san.service

我检查了 /etc/systemd/system我的 san.service 看起来像这样:
-rw-r--r-- 1 root root 193 Apr 2 18:07 san.service

请在这个问题上帮助我,为什么什么都没有运行。

làm mới:环境变量
/etc/systemd/system/san.serviceNội dung:
[Unit]
Description=Description for sample script goes here
After=network.target

[Service]
Type=simple
ExecStart=/opt/horses/startSanic2.sh
TimeoutStartSec=0
Environment="var1=value1"

[Install]
WantedBy=default.target

1 Câu trả lời

更改startSanic2.sh至:

#!/thùng/bash

/opt/horses/startSanic.sh

确保它是可执行的:
$ sudo chmod +x /opt/horses/startSanic2.sh

还要确保 startSanic.sh是可执行的:
$ sudo chmod +x /opt/horses/startSanic.sh

重新加载守护进程并启用它:
$ sudo systemctl daemon-reload
$ sudo systemctl enable san.service
$ sudo systemctl start san.service

重启机器。

làm mới:

hiện hữu san.service 中设置环境变量:
[Unit]
Description=Description for sample script goes here
After=network.target

[Service]
Type=simple
ExecStart=/opt/horses/startSanic2.sh
TimeoutStartSec=0
Environment="REDIS_HOST=192.168.150.220"
Environment="REDIS_PORT=6379"

[Install]
WantedBy=default.target

关于service - Centos 7 - 来自/etc/systemd/system/san.service 的服务未使用 systemctl start san.service 运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55479450/

27 4 0
Bài viết được đề xuất: docker - 容器的 Rancher 静态 IP
Bài viết được đề xuất: numpy - 出于分析目的了解 Numpy 内部结构
Bài viết được đề xuất: tcl - 逻辑非运算符
Bài viết được đề xuất: database - 多主到单从复制
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com