在启动启动中使用raspberry pi中的nodejs时,如何查看控制台



我在启动(rc.local)上使用raspberrypi中的nodejs。如果Nodejs在启动时运行,我的FTP客户端将无法下载数据。但是,如果我自己通过命令行运行,它将很棒,并且能够通过FTP客户端下载文件。

在启动时使用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 %sn" "$_IP"
fi
exit 0

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

您可以键入which node以获取节点二进制的路径

但是,一个更好的选择是使用PM2。它将处理您的节点应用程序的启动加载,处理/显示其日志,在发生错误时重新启动它们。您也可以监视它们,停止,重新启动...

最新更新