Meteor.js - mupx部署给我带来麻烦 - 我该如何解决这个错误?

时间:2015-08-10 19:31:45

标签: meteor

我正在使用mupx将流星应用程序部署到数字海洋。 (使用带有512 MB RAM的5美元小滴)。

部署后,mupx会返回以下错误消息:

> mupx deploy

Meteor Up: Production Quality Meteor Deployments
------------------------------------------------
Configuration file : mup.json
Settings file      : settings.json

Meteor app path    : /Users/me/myapp
Using buildOptions : {}

Started TaskList: Deploy app 'My-App' (linux)
[48.59.198.247] - Uploading bundle
[48.59.198.247] - Uploading bundle: SUCCESS
[48.59.198.247] - Sending environment variables
[48.59.198.247] - Sending environment variables: SUCCESS
[48.59.198.247] - Initializing start script
[48.59.198.247] - Initializing start script: SUCCESS
[48.59.198.247] - Invoking deployment process
[48.59.198.247] - Invoking deployment process: SUCCESS
[48.59.198.247] - Verifying deployment
[48.59.198.247] x Verifying deployment: FAILED

-----------------------------------STDERR-----------------------------------
0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
    curl: (52) Empty reply from server
    npm WARN package.json meteor-dev-bundle@0.0.0 No description
    npm WARN package.json meteor-dev-bundle@0.0.0 No repository field.
    npm WARN package.json meteor-dev-bundle@0.0.0 No README data

    > fibers@1.0.5 install /bundle/bundle/programs/server/node_modules/fibers
    > node ./build.js

    `linux-x64-v8-3.14` exists; testing
    Binary is fine; exiting
    underscore@1.5.2 node_modules/underscore

    semver@4.1.0 node_modules/semver

    eachline@2.3.3 node_modules/eachline
    └── type-of@2.0.1

    chalk@0.5.1 node_modules/chalk
    ├── ansi-styles@1.1.0
    ├── escape-string-regexp@1.0.3
    ├── supports-color@0.2.0
    ├── has-ansi@0.1.0 (ansi-regex@0.2.1)
    └── strip-ansi@0.3.0 (ansi-regex@0.2.1)

    source-map-support@0.2.8 node_modules/source-map-support
    └── source-map@0.1.32 (amdefine@0.1.0)

    fibers@1.0.5 node_modules/fibers
    => Starting meteor app on port:80

    => Redeploying previous version of the app

    ------------------------------STDOUT-----------------------------

    To see more logs type 'mup logs --tail=50'

    -----------------------------------------------------------------

如果我检查服务器上的日志(使用mupx logs -f),我会看到以下内容:

[48.59.198.247] /opt/meteord/run_app.sh: line 36:    16 Killed                  node main.js
[48.59.198.247] npm WARN package.json meteor-dev-bundle@0.0.0 No description
[48.59.198.247] npm WARN package.json meteor-dev-bundle@0.0.0 No repository     field.
[48.59.198.247] npm WARN package.json meteor-dev-bundle@0.0.0 No README data
[48.59.198.247] /opt/meteord/run_app.sh: line 36:    16 Killed                  node main.js
[48.59.198.247] npm WARN package.json meteor-dev-bundle@0.0.0 No description
[48.59.198.247] npm WARN package.json meteor-dev-bundle@0.0.0 No repository field.
[48.59.198.247] npm WARN package.json meteor-dev-bundle@0.0.0 No README data
[48.59.198.247] /opt/meteord/run_app.sh: line 36:    16 Killed                  node main.js
[48.59.198.247] npm WARN package.json meteor-dev-bundle@0.0.0 No description
[48.59.198.247] npm WARN package.json meteor-dev-bundle@0.0.0 No repository field.
[48.59.198.247] npm WARN package.json meteor-dev-bundle@0.0.0 No README data
[48.59.198.247] /opt/meteord/run_app.sh: line 36:    16 Killed                  node main.js

3 个答案:

答案 0 :(得分:3)

我的应用程序很简单,但显然不是轻量级的。我的server/main.js看起来像这样:

Meteor.startup(function () {
    My_LineItems.find({}, {fields: {targeting: 1, id: 1}}).observeChanges({
        changed: function(_id, fields) {
            update_targeting(fields.id, fields.targeting);
        }
    });
    My_LineItems.find({}).observeChanges({
        added: function(_id, fields) {
            update_targeting(fields.id, fields.targeting);
        }
    });
    console.log('The app should be started now...');
});

显然,那些观察这些查询的请求非常慢,以至于它们不允许应用程序启动,在15秒或120秒的deployCheckWaitTime后,应用程序仍未正常启动。

我通过更改上面的代码解决了这个问题:

Meteor.startup(function () {
    Meteor.setTimeout(function() {
        My_LineItems.find({}, {fields: {targeting: 1, id: 1}}).observeChanges({
            changed: function(_id, fields) {
                update_targeting(fields.id, fields.targeting);
            }
        });
        My_LineItems.find({}).observeChanges({
            added: function(_id, fields) {
                update_targeting(fields.id, fields.targeting);
            }
        });
    }, 30);
    console.log('The app should be started now...');
});

通过此调整,我的应用程序能够部署而不会出现问题。

基本上,每次我部署应用程序时,都必须为集合中的每个项目运行added方法,其中有很多项目。我将其放入Meteor.setTimeout()我能够mupx将应用注册为正确启动,然后繁重的流程就可以在后台运行。

答案 1 :(得分:2)

通过简单地增加“deployCheckWaitTime”来解决这个问题。在mup.json中为120(我假设任何合理地高于默认值20的工作)。猜猜它只需要更多时间来处理。

答案 2 :(得分:1)

我已经看到通过使用具有更多RAM的实例解决了其他问题。