将Sails.js应用程序部署到Google App Engine

时间:2016-10-04 11:05:02

标签: node.js google-app-engine sails.js

我正在尝试部署到Google App Engine的新Sails.js应用程序。当我简单地部署框架(使用CLI sails new web-service创建的vanilla Sails.js应用程序)时,它工作得很好。部署发生得很快,我可以通过访问URL来访问该应用程序。

我在/config/connections.js配置了ORM以连接到mLab MongoDB数据库。在此更改之后,应用程序在我的本地计算机上正常工作,但是当我使用终端将其部署到Google App Engine时,我收到以下控制台错误:

Updating service [default]...failed.
ERROR: (gcloud.app.deploy) Error Response: [13] Timed out when starting VMs.  (1/2 ready, 1 still deploying).

npm ERR! Darwin 15.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "deploy"
npm ERR! node v5.11.0
npm ERR! npm  v2.14.5
npm ERR! code ELIFECYCLE
npm ERR! web-service@0.0.0 deploy: `gcloud app deploy --project web-service-staging`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the web-service@0.0.0 deploy script 'gcloud app deploy --project web-service-staging'.
npm ERR! This is most likely a problem with the web-service package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     gcloud app deploy --project web-service-staging
npm ERR! You can get their info via:
npm ERR!     npm owner ls web-service
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/Nag/Code/web-service/npm-debug.log

以下是npm-debug.log的输出:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'deploy' ]
2 info using npm@2.14.5
3 info using node@v5.11.0
4 verbose run-script [ 'predeploy', 'deploy', 'postdeploy' ]
5 info predeploy web-service@0.0.0
6 info deploy web-service@0.0.0
7 verbose unsafe-perm in lifecycle true
8 info web-service@0.0.0 Failed to exec deploy script
9 verbose stack Error: web-service@0.0.0 deploy: `gcloud app deploy --project web-service-staging`
9 verbose stack Exit status 1
9 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:214:16)
9 verbose stack     at emitTwo (events.js:100:13)
9 verbose stack     at EventEmitter.emit (events.js:185:7)
9 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:24:14)
9 verbose stack     at emitTwo (events.js:100:13)
9 verbose stack     at ChildProcess.emit (events.js:185:7)
9 verbose stack     at maybeClose (internal/child_process.js:850:16)
9 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
10 verbose pkgid web-service@0.0.0
11 verbose cwd /Users/Nag/Code/web-service
12 error Darwin 15.5.0
13 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "deploy"
14 error node v5.11.0
15 error npm  v2.14.5
16 error code ELIFECYCLE
17 error web-service@0.0.0 deploy: `gcloud app deploy --project web-service-staging`
17 error Exit status 1
18 error Failed at the web-service@0.0.0 deploy script 'gcloud app deploy --project web-service-staging'.
18 error This is most likely a problem with the web-service package,
18 error not with npm itself.
18 error Tell the author that this fails on your system:
18 error     gcloud app deploy --project web-service-staging
18 error You can get their info via:
18 error     npm owner ls web-service
18 error There is likely additional logging output above.
19 verbose exit [ 1, true ]

是否因为无法连接到mLab数据库而无法启动?如果是的话,为什么呢?在我的本地机器上运行正常。增加超时会有帮助吗?如果是,我该怎么做?

1 个答案:

答案 0 :(得分:1)

好的,我设法通过更改ORM hookTimeout来解决此问题。

/config/env/development.js/config/env/production.js中,我添加了以下内容:

module.exports = {

    // Extends the ORM timeout to connect to the database
    hookTimeout: 240000
};