问题描述
我在咖啡中写了一个节点restify服务器,我似乎无法让它运行。
I have written a node restify server in coffee and I can't seem to get it running.
部署时收到以下错误:
之后会收到以下错误
如果coffeescript似乎是问题是有一个工作。我不想改回js。
If coffeescript seems to be the problem is there a work around it. I would not want to change back to js.
我的服务器代码是:
restify = require 'restify'
Bunyan = require 'bunyan'
server = restify.createServer
name: 'APPNAME'
version: '0.0.1'
log: Bunyan.createLogger
name: 'api'
serializers:
req: ()->
return "bad"
# Usercontroller.access calls a function to process the request
server.post '/user/access', UserController.access
server = create.createServer()
server.listen server_port, ->
console.log "Http server listening on #{server_port}"
require('./document')(server.router.mounts, 'restify')
return
推荐答案
您需要检查的第一步是查看日志下〜 /app-root/logs/nodejs.log
The very first step that you need to check is look at the log under ~/app-root/logs/nodejs.log
在我的情况下,软件包或任何类型的访问都没有问题。我在日志中得到的唯一信息是:
In my case there was no issue with package or any kind of access. The only information that I have got in log is:
原因除了前面的控制台说,它是无法访问8080,然后确保您指定IP地址与端口号。
If you cannot find any reason apart from the front console says that it is unable to access 8080 then make sure that you have specified IP ADDRESS along with PORT Number.
这是我如何修复它。
var express = require('express');
var app = express();
var http = require('http');
app.set('port', process.env.OPENSHIFT_NODEJS_PORT || process.env.PORT || 3002);
app.set('ip', process.env.OPENSHIFT_NODEJS_IP || "127.0.0.1");
http.createServer(app).listen(app.get('port') ,app.get('ip'), function () {
console.log("✔ Express server listening at %s:%d ", app.get('ip'),app.get('port'));
server();
});
UPDATED:
如何进入日志目录:
- 使用命令rhc ssh进入您的设备
- 一次您已登录类型
cd $ OPENSHIFT_LOG_DIR
- SSH into your gear with the command rhc ssh
- Once you are logged in type
cd $OPENSHIFT_LOG_DIR
通过Openshift环境。
There you have logs files stored by Openshift environment.
这篇关于应用程序'appname'无法启动(端口8080不可用)打开移位节点应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!