问题
So here are the steps I've taken so far:
- Created application on openshift
- Cloned application's repo
- Deleted all files for the sample app in the cloned repo
- Added my project files
- Performed a Git-Push which completed successfully.
I still see the default landing page:
The only odd thing I see in the deployment logs this warning, which makes no senses because it's not my code doing that (I'm basically just trying to deploy the sample app from Express)
Any ideas as to what could be causing this? I'm trying to dump Heroku but can't get basic things to work.
UPDATE: I found this KB article which explains how to run your own file (why this information isn't better documented and part of the basic tutorial is beyond me). It is still unclear to me whether the code in server.js is needed or not... Or I'm expected to always use server.js as a shell to all my code.
https://www.openshift.com/kb/kb-e1048-how-can-i-run-my-own-nodejs-script
回答1:
I found the answer here:
https://www.openshift.com/blogs/run-your-nodejs-projects-on-openshift-in-two-simple-steps
The gist of it is this:
- Change main in package.json to set main to yourApp.js (as per this article)
- Make sure you're starting your server with the right IP and Port on OpenShift (see below)
app.set('port', process.env.OPENSHIFT_NODEJS_PORT || 8080);
app.set('ip', process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1');
and then
http.createServer(app).listen(app.get('port'), app.get('ip'), function(){
console.log('Express server listening on port ' + app.get('port'));
});
来源:https://stackoverflow.com/questions/22582725/deployed-node-app-to-openshift-successfully-openshift-still-shows-default-page