重新启动时Openshift节点应用程序错误 [英] Openshift node app error when restarting

查看:90
本文介绍了重新启动时Openshift节点应用程序错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在openshift上托管了一个node/socket.io聊天应用程序,并且如果我ssh进入服务器并执行"node main.js"(其中main.js是启动聊天的服务器脚本),它会正确启动. ,我无法通过Web界面在服务器上启动该应用,因为该应用会自动运行;如果我只是通过ssh启动应用程序,则退出终端后它将立即停止工作.

I have a node/socket.io chat app hosted on openshift, and while it starts correctly if i ssh into the server and do "node main.js" (where main.js is the server script that starts the chat), I can't start the app on the server by web interface, where it would go on automatically; If i just start the app by ssh, it would stop working as soon as i exit the terminal.

通过网络界面启动应用程序时出现此错误:

I get this error when starting the app by the web interface:

    Starting Node.js application...
    Application is already stopped.
    Warning! Could not start Node.js application!
    Failed to execute: 'control restart' for /var/lib/openshift/57003fbe7628e1491d00011e/nodejs

如果相关,我的package.json文件为

In case it's relevant, my package.json file is

{
  "name": "rainychat",
  "version": "1.0.0",
  "description": "rainychat, my chat app",
  "main": "main.js",
  "dependencies": {
    "express": "^4.13.4",
    "socket.io": "^1.4.5",
    "validator": "^5.1.0"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "JG",
  "license": "ISC"
}

在这里您可以通过ftp查看应用程序的文件:

And here you can see the files of the app by ftp:

我无法解读该错误的含义...

I can't decode what that error means...

我的main.js代码

My main.js code

var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);

app.get('/', function (req, res) {
    res.sendFile(__dirname + '/chat.html'); // /home/redadmin/public_html/rainychat.com
    console.log('enviado');
});

app.set('port', process.env.OPENSHIFT_NODEJS_PORT || 8080);
app.set('ip', process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1');

http.listen(app.get('port'), app.get('ip'), function () {
    console.log('Listening on port ' + app.get('port'));
});
//... More code

推荐答案

如果要创建新的Node项目,请从npm init开始创建package.json文件.您可以添加--auto选项以为其提供安全的默认值.

If you're creating a new Node project, start with npm init to create the package.json file. You can add the --auto option to give it safe defaults.

请记住,JSON文件必须是有效的JSON,因此请使用jsonlint在线验证器之类的工具对其进行测试.

Remember, the JSON file must be valid JSON, so test it with jsonlint or a tool like an online validator.

项目的任何依赖项都应在软件包文件中阐明.这是通过npm install express --save之类的东西自动完成的.

Any dependencies your project has should be spelled out in the package file. This is done automatically with things like npm install express --save.

这篇关于重新启动时Openshift节点应用程序错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆