Code Monkey home page Code Monkey logo

Comments (32)

madushan1000 avatar madushan1000 commented on May 21, 2024 3

Yes, The mongo installation mup setup is just a basic one. It's not meant to be used in production at all. Setup your own mongo and use MONG_URL env var instead.

from meteor-up.

Sphinxxxx avatar Sphinxxxx commented on May 21, 2024 1

For the record: Deploying multiple apps to the same server, giving each app separate databases on localhost seems to work just fine. The mup.js files need to have the same mongo configuration:

my-app-111:

module.exports = {
  servers: {
    one: {
      ...
    }
  },

  meteor: {
    name: 'my-app-111',
    path: '../',
    docker: {
      image: 'abernix/meteord:base',
    },
    servers: {
      one: {}
    },
    buildOptions: {
      serverOnly: true,
    },
    env: {
      PORT: 8080,
      ROOT_URL: 'http://app111.mydomain.com',
      MONGO_URL: 'mongodb://localhost/meteor'
    },
    deployCheckWaitTime: 240
  },

  mongo: {
    oplog: true,
    port: 27017,
    servers: {
      one: {},
    },
  },
};

my-app-222:

module.exports = {
  servers: {
    one: {
      ...,
    }
  },

  meteor: {
    name: 'my-app-222',
    path: '../',
    docker: {
      image: 'abernix/meteord:base',
    },
    servers: {
      one: {}
    },
    buildOptions: {
      serverOnly: true,
    },
    env: {
      PORT: 8081,
      ROOT_URL: 'http://app222.mydomain.com',
      MONGO_URL: 'mongodb://localhost/meteor'
    },
    deployCheckWaitTime: 240
  },

  mongo: {
    oplog: true,
    port: 27017,
    servers: {
      one: {},
    },
  },
};

When I access the MongoDB shell on the server (docker exec -it mongodb mongo my-app-111), the databases lie side by side on the same mongo container(?):

> show dbs
admin             0.000GB
local             0.000GB
my-app-111        0.000GB
my-app-222        0.000GB

from meteor-up.

madushan1000 avatar madushan1000 commented on May 21, 2024

You can assign a custom port for meteor app by adding a port field under meteor config. We are planning to add Nginx proxy suppot built in to mup but It'll take some time.

from meteor-up.

dufia avatar dufia commented on May 21, 2024

Hey Madushan!

I've just found out, that if you specify a custom port you will get some errors on 'Verifying Deployment' although the apps seems to be deployed 100% right on the specified port. Maybe its still looking for the app on 80 or something? Have a good day!

env: {
  PORT: 3000,
  ROOT_URL: 'http://myapp.com',
  MONGO_URL: 'mongodb://localhost/meteor'
}


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

  -----------------------------------STDERR-----------------------------------
  a

  > [email protected] install /bundle/bundle/programs/server/node_modules/fibers
  > node ./build.js

  `linux-x64-v8-3.14` exists; testing
  Binary is fine; exiting
  [email protected] node_modules/ansi-regex

  [email protected] node_modules/ansi-styles

  [email protected] node_modules/escape-string-regexp

  [email protected] node_modules/chalk

  [email protected] node_modules/has-ansi

  [email protected] node_modules/supports-color

  [email protected] node_modules/strip-ansi

  [email protected] node_modules/eachline

  [email protected] node_modules/type-of

  [email protected] node_modules/amdefine

  [email protected] node_modules/asap

  [email protected] node_modules/underscore

  [email protected] node_modules/meteor-promise

  [email protected] node_modules/promise

  [email protected] node_modules/source-map-support

  [email protected] node_modules/semver

  [email protected] node_modules/source-map

  [email protected] node_modules/fibers
  => Starting meteor app on port:80
  startup server

  => Redeploying previous version of the app

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

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

  ----------------------------------------------------------------------------
Error: 
-----------------------------------STDERR-----------------------------------
a

> [email protected] install /bundle/bundle/programs/server/node_modules/fibers
> node ./build.js

`linux-x64-v8-3.14` exists; testing
Binary is fine; exiting
[email protected] node_modules/ansi-regex

[email protected] node_modules/ansi-styles

[email protected] node_modules/escape-string-regexp

[email protected] node_modules/chalk

[email protected] node_modules/has-ansi

[email protected] node_modules/supports-color

[email protected] node_modules/strip-ansi

[email protected] node_modules/eachline

[email protected] node_modules/type-of

[email protected] node_modules/amdefine

[email protected] node_modules/asap

[email protected] node_modules/underscore

[email protected] node_modules/meteor-promise

[email protected] node_modules/promise

[email protected] node_modules/source-map-support

[email protected] node_modules/semver

[email protected] node_modules/source-map

[email protected] node_modules/fibers
=> Starting meteor app on port:80
startup server

=> Redeploying previous version of the app

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

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

----------------------------------------------------------------------------
    at /development/node/nauka/meteor/meteor-up/node_modules/nodemiral/lib/coreTasks.js:39:16
    at /development/node/nauka/meteor/meteor-up/node_modules/nodemiral/lib/session.js:146:9
    at Channel.<anonymous> (/development/node/nauka/meteor/meteor-up/node_modules/nodemiral/lib/ssh.js:125:9)
    at Channel.emit (events.js:107:17)
    at SSH2Stream.<anonymous> (/development/node/nauka/meteor/meteor-up/node_modules/nodemiral/node_modules/ssh2/lib/Channel.js:124:14)
    at SSH2Stream.g (events.js:199:16)
    at SSH2Stream.emit (events.js:104:17)
    at parsePacket (/development/node/nauka/meteor/meteor-up/node_modules/nodemiral/node_modules/ssh2/node_modules/ssh2-streams/lib/ssh.js:3435:10)
    at SSH2Stream._transform (/development/node/nauka/meteor/meteor-up/node_modules/nodemiral/node_modules/ssh2/node_modules/ssh2-streams/lib/ssh.js:552:13)
    at SSH2Stream.Transform._read [as __read] (_stream_transform.js:179:10)
    at SSH2Stream._read (/development/node/nauka/meteor/meteor-up/node_modules/nodemiral/node_modules/ssh2/node_modules/ssh2-streams/lib/ssh.js:213:15)
    at SSH2Stream.Transform._write (_stream_transform.js:167:12)
    at doWrite (_stream_writable.js:301:12)
    at writeOrBuffer (_stream_writable.js:288:5)
    at SSH2Stream.Writable.write (_stream_writable.js:217:11)
    at Socket.ondata (_stream_readable.js:540:20)

from meteor-up.

madushan1000 avatar madushan1000 commented on May 21, 2024

It should check for the correct port, Can try adding a deployCheckWaitTime field under meteor config for me? See this comment #38 (comment)

from meteor-up.

dufia avatar dufia commented on May 21, 2024

I did it, it took a little longer but still ended up with the same errors. The newest build of the app is running fine on :3000 anyway, my mup.js:

module.exports = {
  servers: {
    one: {
      "host": "123.32.12.123",
      "username": "root",
      //"password": "password"
      // or pem file (ssh based authentication)
      "pem": "/Users/konradmoskal/.ssh/id_rsa"
    },
  },

  meteor: {
    name: 'myapp',
    path: '/development/node/nauka/meteor/mmameta-client/app',
    servers: {
      one: {},
    },
    env: {
      PORT: 3000,
      ROOT_URL: 'http://myapp.com',
      MONGO_URL: 'mongodb://localhost/27016'
    },
    deployCheckWaitTime: 90,
  },


  mongo: {
    oplog: true,
    port: 27016,
    servers: {
      one: {},
    },
  }
};

from meteor-up.

THPubs avatar THPubs commented on May 21, 2024

@dufia @madushan1000 Thanks it worked! But even though the app is deployed and working, I get the same error dufia gets.

Another small question... when deploying two apps, is it going to use the same mongo container? When I deployed the second app I think it removed the existing mongo container and created a new one!

from meteor-up.

dufia avatar dufia commented on May 21, 2024

@THPubs

when deploying two apps, is it going to use the same mongo container?

Here it gets tricky, you don't really have control over MongoDB when using MUP. I have a Backbone app that uses MongoDB and I would like my Meteor app to share the same DB. Still, I would like to use MUP cause its good software.

Its seems easy to DO, but it isn't. MUP claims to support MongoDB outside of MUP, but fails badly. I tried current MUP, current MUPX and the newest MUP (under development). Neither of them supported MongoDB outside of MUP (or Docker), errors everywhere. Try it yourself. I am waiting for the newest stable of MUP.

from meteor-up.

madushan1000 avatar madushan1000 commented on May 21, 2024

@THPubs @dufia I'll take a look at it and try to figure out what's causing it. BTW We do not advice to use MongoDB setup comes with mup. It's only intended for testing or aery small apps. For a production app, we recommend setting up a MongoDB replicaset on different hosts or somewhere like compose.io and set MONGO_URL in meteor.env.

from meteor-up.

THPubs avatar THPubs commented on May 21, 2024

@madushan1000 Actually this is for a small app. It does give issues if I remove the mongo from the mup.js and just leave the url for the existing one...

mongo: {
  oplog: true,
  port: 27027,
  servers: {
    one: {},
  },
},

I was trying to connect two apps to a single db.

from meteor-up.

dufia avatar dufia commented on May 21, 2024

same here +1

from meteor-up.

THPubs avatar THPubs commented on May 21, 2024

@dufia :-(

Hope we can get a solution soon. The old mup didn't work well with meteor 1.3... Tomorrow I have to launch an app. :-)

from meteor-up.

madushan1000 avatar madushan1000 commented on May 21, 2024

I'm not recommending this in a production environment, but you can set up mongo in the first meteor deployment and remove all of the mongo config and just set the meteor.env.MONGO_URL to mongodb://localhost/yourdbname in the second app.
Can you post the error if this setup is giving any errors?

from meteor-up.

THPubs avatar THPubs commented on May 21, 2024

Thanks I tried that but then faced with a 502 bad gateway error when visit the site. Here's the mup logs :

    [188.166.243.100]/bundle/bundle/programs/server/node_modules/fibers/future.js:300
    [188.166.243.100]                       throw(ex);
    [188.166.243.100]                             ^
    [188.166.243.100]Error: failed to connect to [localhost:27017]
    [188.166.243.100]    at Object.Future.wait (/bundle/bundle/programs/server/node_modules/fibers/future.js:420:15)
    [188.166.243.100]    at new MongoConnection (packages/mongo/mongo_driver.js:213:27)
    [188.166.243.100]    at new MongoInternals.RemoteCollectionDriver (packages/mongo/remote_collection_driver.js:4:16)
    [188.166.243.100]    at Object.<anonymous> (packages/mongo/remote_collection_driver.js:38:10)
    [188.166.243.100]    at Object.defaultRemoteCollectionDriver (packages/underscore/underscore.js:750:1)
    [188.166.243.100]    at new Mongo.Collection (packages/mongo/collection.js:102:40)
    [188.166.243.100]    at Package (packages/cfs_tempstore/packages/cfs_tempstore.js:39:1)
    [188.166.243.100]    at Package (packages/cfs_tempstore/packages/cfs_tempstore.js:394:1)
    [188.166.243.100]    at packages/cfs_tempstore/packages/cfs_tempstore.js:394:1
    [188.166.243.100]    at packages/cfs_tempstore/packages/cfs_tempstore.js:394:1
    [188.166.243.100]    - - - - -
    [188.166.243.100]    at [object Object].<anonymous> (/bundle/bundle/programs/server/npm/npm-mongo/node_modules/mongodb/lib/mongodb/connection/server.js:556:74)
    [188.166.243.100]    at [object Object].emit (events.js:106:17)
    [188.166.243.100]    at [object Object].<anonymous> (/bundle/bundle/programs/server/npm/npm-mongo/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:156:15)
    [188.166.243.100]    at [object Object].emit (events.js:98:17)
    [188.166.243.100]    at Socket.<anonymous> (/bundle/bundle/programs/server/npm/npm-mongo/node_modules/mongodb/lib/mongodb/connection/connection.js:534:10)
    [188.166.243.100]    at Socket.emit (events.js:95:17)
    [188.166.243.100]    at net.js:441:14
    [188.166.243.100]    at process._tickCallback (node.js:448:13)
    [188.166.243.100]npm WARN deprecated This version of npm lacks support for important features,
    [188.166.243.100]npm WARN deprecated such as scoped packages, offered by the primary npm
    [188.166.243.100]npm WARN deprecated registry. Consider upgrading to at least npm@2, if not the
    [188.166.243.100]npm WARN deprecated latest stable version. To upgrade to npm@2, run:
    [188.166.243.100]npm WARN deprecated 
    [188.166.243.100]npm WARN deprecated   npm -g install npm@latest-2
    [188.166.243.100]npm WARN deprecated 
    [188.166.243.100]npm WARN deprecated To upgrade to the latest stable version, run:
    [188.166.243.100]npm WARN deprecated 
    [188.166.243.100]npm WARN deprecated   npm -g install npm@latest
    [188.166.243.100]npm WARN deprecated 
    [188.166.243.100]npm WARN deprecated (Depending on how Node.js was installed on your system, you
    [188.166.243.100]npm WARN deprecated may need to prefix the preceding commands with `sudo`, or if
    [188.166.243.100]npm WARN deprecated on Windows, run them from an Administrator prompt.)
    [188.166.243.100]npm WARN deprecated 
    [188.166.243.100]npm WARN deprecated If you're running the version of npm bundled with
    [188.166.243.100]npm WARN deprecated Node.js 0.10 LTS, be aware that the next version of 0.10 LTS
    [188.166.243.100]npm WARN deprecated will be bundled with a version of npm@2, which has some small
    [188.166.243.100]npm WARN deprecated backwards-incompatible changes made to `npm run-script` and
    [188.166.243.100]npm WARN deprecated semver behavior.
    [188.166.243.100]npm WARN package.json [email protected] No description
    [188.166.243.100]npm WARN package.json [email protected] No repository field.
    [188.166.243.100]npm WARN package.json [email protected] No README data
    [188.166.243.100]=> Starting meteor app on port:80
    [188.166.243.100]
    [188.166.243.100]/bundle/bundle/programs/server/node_modules/fibers/future.js:300
    [188.166.243.100]                       throw(ex);
    [188.166.243.100]                             ^
    [188.166.243.100]Error: failed to connect to [localhost:27017]
    [188.166.243.100]    at Object.Future.wait (/bundle/bundle/programs/server/node_modules/fibers/future.js:420:15)
    [188.166.243.100]    at new MongoConnection (packages/mongo/mongo_driver.js:213:27)
    [188.166.243.100]    at new MongoInternals.RemoteCollectionDriver (packages/mongo/remote_collection_driver.js:4:16)
    [188.166.243.100]    at Object.<anonymous> (packages/mongo/remote_collection_driver.js:38:10)
    [188.166.243.100]    at Object.defaultRemoteCollectionDriver (packages/underscore/underscore.js:750:1)
    [188.166.243.100]    at new Mongo.Collection (packages/mongo/collection.js:102:40)
    [188.166.243.100]    at Package (packages/cfs_tempstore/packages/cfs_tempstore.js:39:1)
    [188.166.243.100]    at Package (packages/cfs_tempstore/packages/cfs_tempstore.js:394:1)
    [188.166.243.100]    at packages/cfs_tempstore/packages/cfs_tempstore.js:394:1
    [188.166.243.100]    at packages/cfs_tempstore/packages/cfs_tempstore.js:394:1
    [188.166.243.100]    - - - - -
    [188.166.243.100]    at [object Object].<anonymous> (/bundle/bundle/programs/server/npm/npm-mongo/node_modules/mongodb/lib/mongodb/connection/server.js:556:74)
    [188.166.243.100]    at [object Object].emit (events.js:106:17)
    [188.166.243.100]    at [object Object].<anonymous> (/bundle/bundle/programs/server/npm/npm-mongo/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:156:15)
    [188.166.243.100]    at [object Object].emit (events.js:98:17)
    [188.166.243.100]    at Socket.<anonymous> (/bundle/bundle/programs/server/npm/npm-mongo/node_modules/mongodb/lib/mongodb/connection/connection.js:534:10)
    [188.166.243.100]    at Socket.emit (events.js:95:17)
    [188.166.243.100]    at net.js:441:14
    [188.166.243.100]    at process._tickCallback (node.js:448:13)

It looks like it's failing to connect to the mongo database. I then removed mongo from both the mups and installed mongo locally and let the apps connect to it. Still not working. The app will only connect to it's own mongo docker container (Also we can't change the port of that mongo container. It use the default one).

from meteor-up.

THPubs avatar THPubs commented on May 21, 2024

Actually I have no other choice... The old mup didn't work. Might be because im using meteor 1.3?

from meteor-up.

madushan1000 avatar madushan1000 commented on May 21, 2024

Old mup should work. Actually, we are not doing anything meteor version specific inside mup. We just use meteor build command with platform specific flags.

The method I posted above should not work actually. We use docker link internally to link mongo container to meteord container. There are some things you can do listed here.
But this means you have to alter options to meteor docker container.
Since this is not a priority for us(most users use external dbs) I'll take some time to implement.
But if someone can send a PR with proper testing, We can accept it.

PS: I found the problem with failing deployment verification(I was not taking the meteor port from proper place). I'll add a fix soon.

from meteor-up.

THPubs avatar THPubs commented on May 21, 2024

Ah thanks :-) I will give another look at the old mup :-)

from meteor-up.

dufia avatar dufia commented on May 21, 2024

@THPubs

I tried to connect two apps to the same database (localhost:27017) with all versions of MUP: Old, MUPX, current. MUPX has the same issues like the current (under development). I think it is because it is inside Docker and you are unable to access localhost. I don't know if it is a feature or a bug, it just doesn't work. #828

@madushan1000

That being said (MUP is unable to access database via localhost:27017), do you think it would work if database was accessed via servers ip address instead? Like http://128.34.32.349:27017

from meteor-up.

madushan1000 avatar madushan1000 commented on May 21, 2024

@dufia Yeah, The mongo setup comes with mup is not meant to be used in production, Let alone two app sharing it(never host your web app and db in the same place, If one goes down, there is a high probability the other will too)

To answer your other question, You would be able to access it trough a public IP(or if you are in a private LAN, private IP) if you configure your firewall to expose the MongoDB port to outside (This is a bad idea, since mup's MongoDB installation doesn't setup any authentication at all, the whole world will be able to access it)

from meteor-up.

dufia avatar dufia commented on May 21, 2024

@madushan1000 @THPubs

Thanks. Now everything is clear, you can easily connect multiple apps to the same database, just not via localhost. You have to allow Mongo to be remotely accessed and use servers IP address. I know, it might be silly for back-end expert but for me it wasn't.

from meteor-up.

madushan1000 avatar madushan1000 commented on May 21, 2024

Yeah, This is because the way docker works. Unless you've linked your mongo container to meteor container, When you refer as localhost, you actually mean docker containers local address. not the docker host's one. BTW even if you want to use a mongo instance on localhost, set it up separately with a username and password and then set MONGO_URL. mup's one is insecure.

from meteor-up.

nizulzaim avatar nizulzaim commented on May 21, 2024

Sorry, if i have two apps, should i set different port for mongo? because i want to make sure two apps are different from others. For example. first app is
mongo: { oplog: true, port: 27017, servers: { one: {}, }, },

and the second app is:

mongo: { oplog: true, port: 27018, servers: { one: {}, }, },

Or I just set it as same port but it actually work different from other app. Sorry, i dont quite understand this part. I use nginx to proxy my application. First app is in port 3000 and second app is port 3002. Although they are in same server, but i dont want it to share same mongo. From what @THPubs said before, it will overwrite the mongo if i create new container

Another small question... when deploying two apps, is it going to use the same mongo container? When I deployed the second app I think it removed the existing mongo container and created a new one!

from meteor-up.

nizulzaim avatar nizulzaim commented on May 21, 2024

Thank you.. You have simple answer but i can understand and it meant alot

from meteor-up.

nizulzaim avatar nizulzaim commented on May 21, 2024

i tried to enable remote access. Then, new mongo url should look like

MONGO_URL: 'mongodb://1.2.3.4/bongkahDevsign'

or

MONGO_URL: 'mongodb://1.2.3.4:27017/bongkahDevsign'

or

MONGO_URL: 'http://1.2.3.4:27017/bongkahDevsign'

or

MONGO_URL: 'http://1.2.3.4/bongkahDevsign'
?

from meteor-up.

madushan1000 avatar madushan1000 commented on May 21, 2024

both of the mongodb:// ones are okay.

from meteor-up.

nizulzaim avatar nizulzaim commented on May 21, 2024

But when i run DEBUG=* mup deploy, here is the output after Pushing Meteor Application Bundle :
Error write ECONNRESET.

when i run `netstat -a' on server, i think it show that my mongodb have already enable remote access.

tcp 0 0 devsign1:27017 *:* LISTEN

Updated:

This problem not show when i run DEBUG=* mup setup. So, the problem is actually when trying to connect to mongodb i think.

from meteor-up.

madushan1000 avatar madushan1000 commented on May 21, 2024

That error has nothing to do with mongo. It's mup saying it can't connect to your server. I'm not sure why.

from meteor-up.

nizulzaim avatar nizulzaim commented on May 21, 2024

i dont know, But after DEBUG=* reconfig, and deployCheckWaitTime: 120, the problem solved. Thank you. Sorry for asking too many question.

from meteor-up.

madushan1000 avatar madushan1000 commented on May 21, 2024

I'm not exactly sure why, Can you post you mup.js file here(remove any passwords and stuff)? I'll take a look.

from meteor-up.

nizulzaim avatar nizulzaim commented on May 21, 2024

`module.exports = {
servers: {
one: {
host: '1.2.3.4',
username: 'root',
pem: './.mykey',
},
},

meteor: {
    name: 'bongkahDevsign',
    path: '../',
    servers: {
        one: {},
    },
    env: {
        PORT: 3002,
        ROOT_URL: 'http://server.com',
        MONGO_URL: 'mongodb://1.2.3.4:27017/bongkahDevsign'
    },
    deployCheckWaitTime: 120,
},

};`

Here is my mup.js.

from meteor-up.

cyclops24 avatar cyclops24 commented on May 21, 2024

@madushan1000 I have a same issue. I deployed application called A and now want to deploy other application called B that use A database. Which configuration needs for do this in MUP?
I done this with older MUP later but newest MUP can't do this.
Is this feature added to new MUP? (I asked because you close this issue)

from meteor-up.

micktaiwan avatar micktaiwan commented on May 21, 2024

This is the solution:
http://meteor-up.com/docs.html#multiple-apps-use-the-same-database

from meteor-up.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.