I tried running my node app on localhost as well as the google VM. The app runs fine if I login to putty\ssh of the Google cloud VM and start the node application (from /opt/app folder). I can login to browser and access the application via the {external ip:port number}.
If I simply reset (or stop\start) the VM , it doesnt start the application. I provided a start up script to start the application as mentioned in the following article :
https://cloud.google.com/nodejs/getting-started/run-on-compute-engine#download_app
I can see the following when the VM is trying to run the startup script file. Is this actually because the dependecy is missing? Because if the package.json was missing it should have failed when I tried to run it manually.
Apr 11 21:15:02 my-app-instance startupscript: /tmp/tmp.XwUPXasPss: line 28: cd: /opt/app/7-gce: No such file or directory
Apr 11 21:15:02 my-app-instance startupscript: npm install
Apr 11 21:15:03 my-app-instance startupscript: npm ERR! install Couldn't read dependencies
Apr 11 21:15:03 my-app-instance startupscript: npm ERR! Linux 3.16.0-4-amd64
Apr 11 21:15:03 my-app-instance startupscript: npm ERR! argv "/opt/nodejs/bin/node" "/usr/bin/npm" "install"
Apr 11 21:15:03 my-app-instance startupscript: npm ERR! node v4.2.2
Apr 11 21:15:03 my-app-instance startupscript: npm ERR! npm v2.14.7
Apr 11 21:15:03 my-app-instance startupscript: npm ERR! path /package.json
Apr 11 21:15:03 my-app-instance startupscript: npm ERR! code ENOPACKAGEJSON
Apr 11 21:15:03 my-app-instance startupscript: npm ERR! errno -2
Apr 11 21:15:03 my-app-instance startupscript: npm ERR! syscall open
Apr 11 21:15:03 my-app-instance startupscript: npm ERR! package.json ENOENT: no such file or directory, open '/package.json'
Apr 11 21:15:03 my-app-instance startupscript: npm ERR! package.json This is most likely not a problem with npm itself.
Apr 11 21:15:03 my-app-instance startupscript: npm ERR! package.json npm can't find a package.json file in your current directory.
Package.json
{
"name": "appname",
"version": "1.0.0",
"description": "An interactive forum",
"main": "server.js",
"private": true,
"engines": {
"node": ">=0.12.7",
"npm": "2.14.12"
},
"dependencies": {
"bluebird": "^3.3.4",
"body-parser": "^1.15.0",
"cors": "^2.7.1",
"express": "^4.13.4",
"jsonfile": "^2.2.3",
"mysql": "^2.10.2",
"socket.io": "^1.4.5"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "app, test, ineractive"
},
"keywords": [
"app",
"test",
"interactive"
],
"author": "Srikanth",
"license": "MIT"
}
Any help would be appreciated ? Also it gives an error in the "supervisor" logs.
2016-04-11 21:15:09,694 INFO exited: nodeapp (exit status 127; not expected)
2016-04-11 21:15:10,695 INFO gave up: nodeapp entered FATAL state, too many start retries too quickly
See the log line line 28: cd: /opt/app/7-gce: No such file or directory
: In the linked instructions, it assumes your app lives in that directory. However, you appear not to have it on your VM, which causes the rest of the script to fail.