在Openshift上部署的Sails.js项目的可视化错误

时间:2014-05-21 15:48:33

标签: node.js gruntjs openshift sails.js ejs

我在Openshift上部署了我的Sails项目。 它工作但我收到websockets的错误,我无法加载构建在ejs上的页面。

我发现这些链接对grunt / openshift有足够的解释,但我无法解决问题。

Deploying Sails.js On Openshift

Deploy Sails.js on Openshift ... app restarting over and over

我的nodejs.log是:

DEBUG: Running node-supervisor with
DEBUG:   program 'app.js'
DEBUG:   --watch '/var/lib/openshift/537b5ae8500446c95900057f/app-root/data/.nodewatch'
DEBUG:   --ignore 'undefined'
DEBUG:   --extensions 'node|js|coffee'
DEBUG:   --exec 'node'
DEBUG: Starting child process with 'node app.js'
DEBUG: Watching directory '/var/lib/openshift/537b5ae8500446c95900057f/app-root/data/.nodewatch' for changes.
Warning: connection.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and will not scale past a single process.
^[[32minfo^[[39m:
^[[32minfo^[[39m:
^[[32minfo^[[39m:    Sails.js           <|
^[[32minfo^[[39m:    v0.9.16             |\
^[[32minfo^[[39m:                       /|.\
^[[32minfo^[[39m:                      / || \
^[[32minfo^[[39m:                    ,'  |'  \
^[[32minfo^[[39m:                 .-'.-==|/_--'
^[[32minfo^[[39m:                 `--'-------'
^[[32minfo^[[39m:    __---___--___---___--___---___--___
^[[32minfo^[[39m:  ____---___--___---___--___---___--___-__
^[[32minfo^[[39m:
^[[32minfo^[[39m: Server lifted in `/var/lib/openshift/537b5ae8500446c95900057f/app-root/runtime/repo`
^[[32minfo^[[39m: To see your app, visit http://127.2.95.129:8080
^[[32minfo^[[39m: To shut down Sails, press <CTRL> + C at any time.
^[[34mdebug^[[39m: --------------------------------------------------------
^[[34mdebug^[[39m: :: Wed May 21 2014 14:26:01 GMT-0400 (EDT)
^[[34mdebug^[[39m:
^[[34mdebug^[[39m: Environment  : production
^[[34mdebug^[[39m: Host         : 127.2.95.129
^[[34mdebug^[[39m: Port         : 8080
^[[34mdebug^[[39m: --------------------------------------------------------
^[[31merror^[[39m: Server doesn't seem to be starting.
^[[31merror^[[39m: Perhaps something else is already running on port 8080 with hostname 127.2.95.129?
^[[32minfo^[[39m: handshake authorized qR_aOT3qx40k6X34CF-2
^[[32minfo^[[39m: handshake authorized tnAUouwi-d32h82rCF-3
^[[33mwarn^[[39m: websocket connection invalid
^[[32minfo^[[39m: transport end (undefined)
^[[31merror^[[39m: Error rendering view at :: /var/lib/openshift/537b5ae8500446c95900057f/app-root/runtime/repo/views/viewshows/index
^[[31merror^[[39m: Using layout located at :: /var/lib/openshift/537b5ae8500446c95900057f/app-root/runtime/repo/views/layout
^[[31merror^[[39m: Error: Failed to lookup view "viewshows/index"
    at Function.app.render (/var/lib/openshift/537b5ae8500446c95900057f/app-root/runtime/repo/node_modules/sails/node_modules/express/lib/application.js:495:17)
    at ServerResponse.res.render (/var/lib/openshift/537b5ae8500446c95900057f/app-root/runtime/repo/node_modules/sails/node_modules/express/lib/response.js:798:7)
    at ServerResponse._addResViewMethod.res.view (/var/lib/openshift/537b5ae8500446c95900057f/app-root/runtime/repo/node_modules/sails/lib/hooks/views/index.js:297:15)
    at module.exports.index (/var/lib/openshift/537b5ae8500446c95900057f/app-root/runtime/repo/api/controllers/ViewShowsController.js:32:13)
    at _bind.enhancedFn (/var/lib/openshift/537b5ae8500446c95900057f/app-root/runtime/repo/node_modules/sails/lib/router/bind.js:375:4)
    at callbacks (/var/lib/openshift/537b5ae8500446c95900057f/app-root/runtime/repo/node_modules/sails/node_modules/express/lib/router/index.js:164:37)

这是我的app.js:

require('sails').lift(require('optimist').argv);

这是我的local.js:

module.exports = {
  host: process.env.OPENSHIFT_NODEJS_IP || "127.0.0.1",
  port: process.env.OPENSHIFT_NODEJS_PORT || 8080,
  environment: process.env.NODE_ENV || 'development'
}

调用'env |我收到的openshift控制台上的grep OPENSHIFT_NODEJS_PORT':

OPENSHIFT_NODEJS_PORT=8080

在我看来,问题不在于港口。服务器启动并正确回答。 但是当我打电话给一个建在ejs上的页面时,它会用一块json回答我......

{"view":{"name":"viewshows/index","root":"/var/lib/openshift/537b5ae8500446c95900057f/app-root/runtime/repo/views","defaultEngine":"ejs","ext":".ejs"}}

...并在服务器日志中打印上述错误。

有什么建议吗?

由于

1 个答案:

答案 0 :(得分:0)

我非常确定openshift要求你的应用程序监听由环境变量指定的特定端口,而不是8080

您希望将app.js更改为使用此openshift doc

中的主机名和端口env变量