[英]Node.js on Plesk not starting
我已经安装了Node.js扩展程序,但我的应用程序无法运行。 我有一个Symfony 4应用程序,正在使用socket.io进行套接字通信。 现在,我需要启动socket.js来启动服务器。 该文件位于resources / js文件夹中。
所以我设置了Node.js如下:
Document Root: /application.domain.com/public
Application Mode: production
Application URL: This site is under development
Application Root: /application.domain.com
Application Startup File: resources/js/socket.js
Custom environment variables:
但是,当我启动该应用程序时,它无法正常工作。 当我像这样从CLI(SSH连接)运行socket.js文件时
/opt/plesk/node/8/bin/node socket.js
一切正常。 但是现在我需要保持SSH连接保持活动状态,并且没有检查socket.js是否仍在运行。 我想Node.js扩展也可以解决这个问题。
如何使用此Node.js扩展名启动我的socket.js? 还是我可以用其他方式做到这一点?
好的,我使用Systemd解决了另一种问题。
在https://www.axllent.org/docs/view/nodejs-service-with-systemd/上找到了这一点,因此感谢Ralph Slooten。
创建服务文件
/etc/systemd/system/nodeserver.service
内容
[Unit]
Description=Node.js Example Server
#Requires=After=mysql.service # Requires the mysql service to run first
[Service]
ExecStart=/usr/local/bin/node /opt/nodeserver/server.js
# Required on some systems
#WorkingDirectory=/opt/nodeserver
Restart=always
# Restart service after 10 seconds if node service crashes
RestartSec=10
# Output to syslog
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=nodejs-example
#User=<alternate user>
#Group=<alternate group>
Environment=NODE_ENV=production PORT=1337
[Install]
WantedBy=multi-user.target
启用服务
systemctl enable nodeserver.service
启动服务
systemctl start nodeserver.service
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.