当作为服务运行时出现“没有这样的文件或目录”错误?

huangapple go评论110阅读模式
英文:

No such file or directory when run as service?

问题

当我从终端运行我的应用程序 sudo -u www-data ./scarga 并打开浏览器时,模板文件能够正常提供服务,一切都正常。命令是在 /var/www/html/scarga.local/ 目录下执行的。

当我以 sudo service scarga start 的方式运行我的应用程序时,它显示:open ./resources/views/index.html: no such file or directory

具有HTTP处理程序的文件:https://pastebin.com/MU7YDAWV

scarga.service 文件:https://pastebin.com/eBL3jJFx

项目的目录树:https://pastebin.com/rFVa8A3P

index.html 文件的权限为:
-rwxr-xr-x 1 www-data www-data 3586 Jun 28 14:27 index.html

为什么会出现这种情况,如何解决?

谢谢!

英文:

When i run my application from terminal sudo -u www-data ./scarga and open browser, the template file served well, everything ok. Command executed from /var/www/html/scarga.local/ directory.

When i run my application as sudo service scarga start it says: open ./resources/views/index.html: no such file or directory

File with HTTP handler: https://pastebin.com/MU7YDAWV

The scarga.service file: https://pastebin.com/eBL3jJFx

Tree of project: https://pastebin.com/rFVa8A3P

Rights for index.html file
-rwxr-xr-x 1 www-data www-data 3586 Jun 28 14:27 index.html`

Why this happens and how to solve?

Thank you!

答案1

得分: 2

你需要在脚本中使用WorkingDirectory=来设置正确的工作目录,可能是这样的:

WorkingDirectory=/var/www/html/scarga.local
英文:

You need to set the correct working directory in your script using WorkingDirectory= - presumably:

WorkingDirectory=/var/www/html/scarga.local

huangapple
  • 本文由 发表于 2017年6月29日 02:52:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/44810434.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定