GCloud VM 实例未启动节点应用程序
GCloud VM instance not starting Node app
我尝试 运行 在本地主机和 google VM 上安装我的节点应用程序。如果我登录到 Google 云虚拟机的 putty\ssh,应用程序 运行 没问题
并启动节点应用程序(从 /opt/app 文件夹)。我可以登录浏览器并通过{外部 ip:port 号码}访问应用程序。
如果我只是重置(或stop\start)虚拟机,它不会启动应用程序。我提供了一个启动脚本来启动应用程序
在以下文章中提到:
https://cloud.google.com/nodejs/getting-started/run-on-compute-engine#download_app
当 VM 尝试 运行 启动脚本文件时,我可以看到以下内容。这实际上是因为缺少依赖关系吗?
因为如果 package.json 丢失,当我尝试手动 运行 时它应该会失败。
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"
}
任何帮助将不胜感激?它还在 "supervisor" 日志中给出错误。
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
查看日志行 line 28: cd: /opt/app/7-gce: No such file or directory
:在链接的说明中,它假定您的应用位于该目录中。但是,您的 VM 上似乎没有它,这会导致脚本的其余部分失败。
我尝试 运行 在本地主机和 google VM 上安装我的节点应用程序。如果我登录到 Google 云虚拟机的 putty\ssh,应用程序 运行 没问题 并启动节点应用程序(从 /opt/app 文件夹)。我可以登录浏览器并通过{外部 ip:port 号码}访问应用程序。
如果我只是重置(或stop\start)虚拟机,它不会启动应用程序。我提供了一个启动脚本来启动应用程序 在以下文章中提到:
https://cloud.google.com/nodejs/getting-started/run-on-compute-engine#download_app
当 VM 尝试 运行 启动脚本文件时,我可以看到以下内容。这实际上是因为缺少依赖关系吗? 因为如果 package.json 丢失,当我尝试手动 运行 时它应该会失败。
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"
}
任何帮助将不胜感激?它还在 "supervisor" 日志中给出错误。
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
查看日志行 line 28: cd: /opt/app/7-gce: No such file or directory
:在链接的说明中,它假定您的应用位于该目录中。但是,您的 VM 上似乎没有它,这会导致脚本的其余部分失败。