我是 golang 的新手,正在尝试在我的服务器上托管一个简单的网站。
我在 Ubuntu 18.04
我的域根目录在/var/www/vhosts/mydomain.com/mydomain.com
我有一个main.go文件,它在浏览器中呈现一个简单的 Hello World。
当我go run main.go离开这个目录时,网页工作正常。
现在我正在尝试创建一项服务,以便在我关闭我的shell.
为此,我创建了一个新service的golangweb.serviceat /etc/systemd/system。
该文件的内容是:
[Unit]
Description = Go Server
[Service]
ExecStart=/var/www/vhosts/mydomain.com/mydomain.com
Type=simple
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
保存文件后,我按顺序插入以下命令:
sudo systemctl daemon-reload
sudo systemctl enable golangweb.service
sudo systemctl start golangweb.service
sudo systemctl status golangweb.service
当我尝试获取状态时,出现以下错误(我在那里删除了一些数据):
golangweb.service - Go Server
Loaded: loaded (/etc/systemd/system/golangweb.service; enabled; vendor preset: enabl
Active: activating (auto-restart) (Result: exit-code) since Fri xx-xx-xx 23:43:52
**Process: xx ExecStart=/var/www/vhosts/mydomain.com/mydomain.com (code=exited, sta
Main PID: xx (code=exited, status=203/EXEC)**
Mai xx xx:xx:xx xxxxx.xxxx.xxxx.systemd[1]: golangweb.service: Failed with re
Warning: Journal has been rotated since unit was started. Log output is incomplete or u
lines 1-8/8 (END)
● golangweb.service - Go Server
Loaded: loaded (/etc/systemd/system/golangweb.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Fri xx-xx-xx xx:xx:xx CEST; 3s ago
Process: xx ExecStart=/var/www/vhosts/mydomain.com/mydomain.com (code=exited, status=203/EXEC)
Main PID: xx (code=exited, status=203/EXEC)
Mai xx xx:xx:xx xxxx.xx.xx xx[1]: golangweb.service: Failed with result 'exit-code'.
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
有人知道为什么会这样吗?
慕虎7371278
相关分类