2017-11-25 353 views
-1

我在启动时使用了Raspberrypi中的NodeJs(rc.local)。我有一些问题,如果NodeJs在启动时运行,我的ftp客户端将无法下载数据。 但如果我通过我自己的命令行运行,它将很好地工作,并且能够通过FTP客户端下载文件。在启动时在树莓派中使用nodejs时,如何查看控制台

有什么方法可以在启动时使用nodejs来查看控制台日志。

我的项目已经很晚了,请帮忙。

在此先感谢。

rc.local中

`#!/bin/sh -e 
# 
# rc.local 
# 
# This script is executed at the end of each multiuser runlevel. 
# Make sure that the script will "exit 0" on success or any other 
# value on error. 
# 
# In order to enable or disable this script just change the execution 
# bits. 
# 
# By default this script does nothing. 

#sudo neo4j start & 
#sudo su pi -c 'sudo neo4j start < /dev/null &' 
#sudo su pi -c 'sudo /etc/init.d/mysql start < /dev/null &' 
sudo su pi -c 'node /home/pi/Desktop/RaspberyryPiLearning/bin/www < 
/home/pi/Desktop/error.log &' 


# Print the IP address 
_IP=$(hostname -I) || true 
if [ "$_IP" ]; then 
printf "My IP address is %s\n" "$_IP" 
fi 

exit 0 
+0

请帮助我需要你的帮助。 –

+0

你可以发布你的rc.local的内容吗? – LMokrane

+0

添加rc.local请看看并为延迟感到抱歉 –

回答

0

应指定node二进制文件,您的节点应用程序的完整路径,例如:sudo su pi -c '/usr/bin/node /home/pi/node_app/index.js

您可以键入which node得到节点二进制

的路径,但,更好的选择是使用PM2。它将处理节点应用程序的启动加载,处理/显示其日志,并在出现错误时重新启动它们。你也可以监控他们,停止,重新启动...