我已经设法让 Sails js 应用程序在服务器上运行,目前仅使用 nohup 运行以在 SSH 会话结束时保持服务运行。
显然,这不是一个非常健壮的解决方案。如果应用程序崩溃或服务器被重置等会发生什么?我正在使用 Fedora,所以我正在使用 systemd。
这是我到目前为止所拥有的。
ExecStart=/usr/bin/node /home/dashboard-app/app.js
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=dashboard-app
User=***
Group=***
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target
服务启动正常,但脚本不知道配置文件,因此默认使用 Sails 端口 1337。转到服务器上的该端口也不起作用。
我还使用sails 配置文件中设置的端口设置了nginx,它工作正常,但我认为这不会有所作为。