MUP: Multiple apps on `Difference Server` use the same database?


#1

Mup version (1.4.5):

  • Mup config app1
module.exports = {
    servers: {
        one: {
            // TODO: set host address, username, and authentication method
             host: "app1-ip",

            username: "root",
            pem: "~/.ssh/id_rsa"
        }
    },

    meteor: {
        // TODO: change app name and path
        name: "myapp",
        path: "../myapp",

        servers: {
            one: {}
        },

        buildOptions: {
            serverOnly: true
        },

        env: {
             ROOT_URL: "http://app1-ip",
             MONGO_URL: "mongodb://localhost/microfisdb",
        },

        deployCheckWaitTime: 120,
        docker: {
            image: "abernix/meteord:base",
            args: [
            ]
        },

        // Show progress bar while uploading bundle to server
        // You might need to disable it on CI servers
        enableUploadProgressBar: true
    },

     mongo: {
         oplog: true,
         port: 27017,
         version: "3.4.1",
         servers: {
             one: {}
         }
     }
};
---
Work fine
  • Mup config app2
module.exports = {
    servers: {
        one: {
            // TODO: set host address, username, and authentication method
             host: "app2-ip",

            username: "root",
            pem: "~/.ssh/id_rsa"
        }
    },

    meteor: {
        // TODO: change app name and path
        name: "myapp",
        path: "../myapp",

        servers: {
            one: {}
        },

        buildOptions: {
            serverOnly: true
        },

        env: {
             ROOT_URL: "http://app2-ip",
             MONGO_URL: "mongodb://root:password@app2-ip:27017/microfisdb",
        },

        deployCheckWaitTime: 120,
        docker: {
            image: "abernix/meteord:base",
            args: [
            ]
        },

        // Show progress bar while uploading bundle to server
        // You might need to disable it on CI servers
        enableUploadProgressBar: true
    },
};

Get error

Started TaskList: Start Meteor
[128.199.242.179] - Start Meteor
[128.199.242.179] - Start Meteor: SUCCESS
[128.199.242.179] - Verifying Deployment
[128.199.242.179] x Verifying Deployment: FAILED

	      ------------------------------------STDERR------------------------------------
	      pologies/server.js:313:35)
	    at emitOne (events.js:77:13)
	    at [object Object].emit (events.js:169:7)
	    at [object Object].<anonymous> (/built_app/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/connection/pool.js:271:12)
	    at [object Object].g (events.js:260:16)
	    at emitTwo (events.js:87:13)
	    at [object Object].emit (events.js:172:7)
	    at Socket.<anonymous> (/built_app/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/connection/connection.js:175:10)
	    at Socket.g (events.js:260:16)
	    at emitNone (events.js:67:13)
	=> Starting meteor app on port:80

	/built_app/programs/server/node_modules/fibers/future.js:313
							throw(ex);
							^
	MongoError: failed to connect to server [..............] on first connect
	    at Object.Future.wait (/built_app/programs/server/node_modules/fibers/future.js:449:15)
	    at new MongoConnection (packages/mongo/mongo_driver.js:219:27)
	    at new MongoInternals.RemoteCollectionDriver (packages/mongo/remote_collection_driver.js:4:16)
	    at Object.<anonymous> (packages/mongo/remote_collection_driver.js:38:10)
	    at Object.defaultRemoteCollectionDriver (packages/underscore.js:784:19)
	    at new Mongo.Collection (packages/mongo/collection.js:103:40)
	    at AccountsServer.AccountsCommon (packages/accounts-base/accounts_common.js:23:18)
	    at new AccountsServer (packages/accounts-base/accounts_server.js:18:5)
	    at meteorInstall.node_modules.meteor.accounts-base.server_main.js (packages/accounts-base/server_main.js:9:12)
	    at fileEvaluate (packages/modules-runtime.js:181:9)
	    - - - - -
	    at [object Object].<anonymous> (/built_app/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/topologies/server.js:313:35)
	    at emitOne (events.js:77:13)
	    at [object Object].emit (events.js:169:7)
	    at [object Object].<anonymous> (/built_app/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/connection/pool.js:271:12)
	    at [object Object].g (events.js:260:16)
	    at emitTwo (events.js:87:13)
	    at [object Object].emit (events.js:172:7)
	    at Socket.<anonymous> (/built_app/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/connection/connection.js:175:10)
	    at Socket.g (events.js:260:16)
	    at emitNone (events.js:67:13)
	=> Starting meteor app on port:80

	/built_app/programs/server/node_modules/fibers/future.js:313
							throw(ex);
							^
	MongoError: failed to connect to server [.............] on first connect
	    at Object.Future.wait (/built_app/programs/server/node_modules/fibers/future.js:449:15)
	    at new MongoConnection (packages/mongo/mongo_driver.js:219:27)
	    at new MongoInternals.RemoteCollectionDriver (packages/mongo/remote_collection_driver.js:4:16)
	    at Object.<anonymous> (packages/mongo/remote_collection_driver.js:38:10)
	    at Object.defaultRemoteCollectionDriver (packages/underscore.js:784:19)
	    at new Mongo.Collection (packages/mongo/collection.js:103:40)
	    at AccountsServer.AccountsCommon (packages/accounts-base/accounts_common.js:23:18)
	    at new AccountsServer (packages/accounts-base/accounts_server.js:18:5)
	    at meteorInstall.node_modules.meteor.accounts-base.server_main.js (packages/accounts-base/server_main.js:9:12)
	    at fileEvaluate (packages/modules-runtime.js:181:9)
	    - - - - -
	    at [object Object].<anonymous> (/built_app/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/topologies/server.js:313:35)
	    at emitOne (events.js:77:13)
	    at [object Object].emit (events.js:169:7)
	    at [object Object].<anonymous> (/built_app/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/connection/pool.js:271:12)
	    at [object Object].g (events.js:260:16)
	    at emitTwo (events.js:87:13)
	    at [object Object].emit (events.js:172:7)
	    at Socket.<anonymous> (/built_app/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/connection/connection.js:175:10)
	    at Socket.g (events.js:260:16)
	    at emitNone (events.js:67:13)
	=> Starting meteor app on port:80

	=> Redeploying previous version of the app


	      ------------------------------------STDOUT------------------------------------
	      Container has no IP Address, likely from the app crashing.
	=> Container status:
	restarted: 4 times {"Bridge":"","SandboxID":"8821ecaf1309f47d05cd7845b3dbef132b3dab6946ab4227f9bd888d46586885","HairpinMode":false,"LinkLocalIPv6Address":"","LinkLocalIPv6PrefixLen":0,"Ports":{"80/tcp":[{"HostIp":"0.0.0.0","HostPort":"123"}]},"SandboxKey":"/var/run/docker/netns/8821ecaf1309","SecondaryIPAddresses":null,"SecondaryIPv6Addresses":null,"EndpointID":"d1964c84b45d886daf62e5cd841532b38b1b778985c90a4862d4e64d69358acc","Gateway":"172.17.0.1","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"IPAddress":"172.17.0.3","IPPrefixLen":16,"IPv6Gateway":"","MacAddress":"02:42:ac:11:00:03","Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"NetworkID":"17211fe075759981e4b50dba3b635dd2eef1f5da60cada8ddcf2cdd1ed8e0a3f","EndpointID":"d1964c84b45d886daf62e5cd841532b38b1b778985c90a4862d4e64d69358acc","Gateway":"172.17.0.1","IPAddress":"172.17.0.3","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"MacAddress":"02:42:ac:11:00:03","DriverOpts":null}}} {"Status":"running","Running":true,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":6633,"ExitCode":0,"Error":"","StartedAt":"2018-09-14T08:12:15.972309113Z","FinishedAt":"2018-09-14T08:12:15.537094409Z"}
	=> Logs:

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

#2

I’m not super familiar with MUP - we use a variant of it for deployments but our mongo db is hosted elsewhere - I suspect your problem is that by default mup only opens and forwards port 80 to your app - take a look at the config options in mup (and docker) for opening additional ports. Also, ensure your machines firewall is configured to allow traffic on the mongo port


#3

thanks for your reply, but not understand.
could explain or example


#4

mup deploys a docker container.

By default docker containers are secured - they dont forward any ports from the host into the docker container

You can specify that a docker container SHOULD forward specific ports. This is how mup forwards traffic to your meteor server in the docker container.

TBH - if you’re looking at sharing a database between servers, you should probably just host mongo on a separate server.


#5

Which mongo hosting (low price)?