gpt4 book ai didi

javascript - Openshift不会运行nodejs应用程序

转载 作者:行者123 更新时间:2023-12-03 10:15:18 25 4
gpt4 key购买 nike

我试图在我的 openshift 服务器上使用 socket.io 运行我的聊天程序,但是每当我尝试重新加载它给我的链接时,它只是一直说:“503 服务错误”。我已经正确设置了我的存储库,并使用 rhc 客户端将我的 ssh key 输入到 openshift 中,但无济于事,我使用端口 3000,我也尝试了端口 80,但它们都不起作用。

这是我的服务器代码和我的 package.json:

var express = require("express"),
app = express(),
http = require("http").Server(app),
io = require("socket.io")(http),
require("./index.js");

app.use(express.static("static"));

io.on("connection", function(socket) {
console.log("a user connnected");
socket.on("disconnect", function() {
console.log("user disconnected");
});

socket.on("chat message", function(msg) {
console.log("message " + msg);
io.emit("chat message", {m: msg.m, u: msg.u});
});
});


var port;

if(process.argv[2]) {port = process.argv[2]} else {port = 3000}

http.listen(port, function() {
console.log("chat listening on port " + port + ".");
});

还有我的 package.json:

{
"name": "ChatterBox",
"version": "1.0.0",
"description": ".",
"main": "index.js",
"dependencies": {
"express": "^4.12.3",
"socket.io": "^1.3.5"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/OrganTrouble/ChatterBox.git"
},
"author": "Jesse Davda",
"license": "ISC",
"bugs": {
"url": "https://github.com/OrganTrouble/ChatterBox/issues"
},
"scripts" {
"start": "node $relative_path_from_repo_dir/index.js"
},
"homepage": "https://github.com/OrganTrouble/ChatterBox"
}

最佳答案

关于javascript - Openshift不会运行nodejs应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29903562/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com