[英]Can't open text file when running a javascript file as a systemd service
I'm running a javascript file from node on my raspberry pi on startup automatically by using systemd service. 我正在通过使用systemd服务在启动时自动从树莓派上的 节点运行javascript文件。
I loosely followed this guide to do the above. 我松散地按照本指南进行上述操作。
When I run my javascript file manually using the command: Node Cloversale.js 当我使用以下命令手动运行javascript文件时:Node Cloversale.js
it runs fine, and reads from my files as expected. 它运行正常,并按预期从我的文件中读取。
However, when running it as a service I get the following errors: 但是,将其作为服务运行时,出现以下错误:
Feb 12 17:48:19 sensohub systemd[1]: Started Clover Service.
Feb 12 17:48:24 sensohub node[8640]: 2018-02-12 17:48:24.028 INFO ENOENT: no such file or directory, open 'token.txt'
Feb 12 17:48:24 sensohub node[8640]: Error: ENOENT: no such file or directory, open 'token.txt'
Feb 12 17:48:24 sensohub node[8640]: at Error (native)
Feb 12 17:48:24 sensohub node[8640]: 2018-02-12 17:48:24.068 INFO ENOENT: no such file or directory, open 'endpoint.txt'
Feb 12 17:48:24 sensohub node[8640]: Error: ENOENT: no such file or directory, open 'endpoint.txt'
Feb 12 17:48:24 sensohub node[8640]: at Error (native)
Feb 12 17:48:24 sensohub node[8640]: 2018-02-12 17:48:24.117 INFO Connected to OCR-Pi Server
I tried using chmod 644 on my services file, so I don't think its a permissions issue, but thats what other sites I've read seem to indicate. 我尝试在服务文件上使用chmod 644,所以我认为它不是权限问题,但这就是我阅读的其他网站似乎所表明的。
Here is my clover.services file: 这是我的clover.services文件:
[Unit]
Description=Clover Service
After=multi-user.target
[Service]
Type=idle
ExecStart=/usr/bin/node /home/pi/OCR-Pi/NSR/cloversale.js
[Install]
WantedBy=multi-user.target
Right after posting this I figured it out... Apparently I had to give read and write permissions to both the Javascript file and the .service file. 发布此消息后,我立即发现了...显然,我必须同时授予Javascript文件和 .service文件的读写权限。
so typing chmod 644 cloversale.js
fixed the issue. 因此,输入
chmod 644 cloversale.js
此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.