Meteor on OpenShift with Ionic2

Hi All,

I am new to Meteor. I am trying to deploy the Meteor Server to OpenShift, but am struggling to understand what I need to do. Any help will be appreciated.

I think I have deployed it, but not sure how to access the server, or to get a mobile app to access the server.

Please see the following for more details.

Thanks

At a minimum you’ll need to know the ip address (or domain if you have registered one) of your server on OpenShift. You can then set your mobile app to access it.

What’s your mobile app? Is it the same meteor project and you added android or ios with meteor add-platform ios etc?

1 Like

Hi Peter,

Thanks for your reply.

The domain is nodejs-easyjobs.rhcloud.com (54.208.77.250) on the OpenShift server, I can ping this successfully.

I am using Ionic 2 to build the mobile app. I am currently just running on Android, but plan to add iOS and Windows.

I am following this tutorial, and it runs on localhost. However, I am not sure where this is configured. I guess localhost is default, and you need to change it to a different host if needs be.

If I check my OpenShift server (nodejs-easyjobs.rhcloud.com) via ssh, I can see that the contents of the Meteor bundle directory is on the server. So Git is pushing the code.

The part I don’t understand is:

  • Do I need to configure Meteor differently for being on the OpenShift Server? Or do I just leave it as is?
  • Where do I configure the client (Ionic 2) to point to the OpenShift server?

There’s a -server argument to meteor build. Which also should work with meteor run in case you are using the android or iOS build targets. I haven’t used it in a year and I’d scripted it but I can see if I can dig it out if you can’t work it out.

Try meteor help build to see if it gives you the arguments. I’m on my phone but will have a look later.

Edit: also I haven’t done anything with ionic but if it’s just a front end library and it’s all just the one meteor app (server and phone build) then I think the above is the way to do it.

Can you just confirm whether that’s just a package or script you add to the same meteor project that has your server code or a completely separate project?

Hi Peter,

I will have a look for the -server argument.

I am pretty new to Ionic, and very new to Meteor, so please excuse my ignorance.

My dir structure:

openshift-appname
.../ionic-apps/nodejs/bundle/server/...
meteorapp
.../ionic-aps/myIonicApp/api/.meteor/...
.../ionic-aps/myIonicApp/api/server/...

The contents of the.../ionic-apps/nodejs is cloned on the OpenShift server with Git.

I followed this tutorial to deploy the Meteor bundle to OpenShift. `

So I used the following to build my Meteor app:

> cd .../ionic-aps/myIonicApp/
> meteor build .../ionic-apps/nodejs --directory --server-only

As far as I can see, I may be wrong, but the Meteor Server is all correct and running on OpenShift. I need to know how I can get my Ionic2 app to access it.

  • Step1: Find the access point to the Meteor server using the OpenShift IP nodejs-easyjobs.rhcloud.com (54.208.77.250).

  • Step2: Configure my Ionic2 client to use this.

Yeah okay, sorry ionic is outside of my experience.

I don’t think the server build part is the issue though. You need to point your mobile app to the server which was why I was asking if the mobile app is also a meteor project and the same meteor project. If it isn’t then that -server flag isn’t going to be relevant.

Thank you for all your help.

I have just found the following, which talks about Angular (Ionic) & Meteor, so it may help.

http://www.angular-meteor.com/

1 Like

This may provide some answers. He is looking to do exactly what I am.

1 Like

You could change any of them to test it but that production URL would be have to be changed to point to your server in your deployed app.

Edit: sorry mobile not production.

It’s guess work on my part not having built an app like that but it seems like a reasonable guess.

Thanks, yes I will probably just code the url in.

Another question:
For Meteor running on the remote server (OpenShift), should I be able to ping it on port 3000?

ping success

> ping nodejs-easyjobs.rhcloud.com

Ping request could not find host

> ping nodejs-easyjobs.rhcloud.com:3000

Also, this may sound like a dumb question, but on the remote server, do I need to run the following cmd to strt the server?

> meteor

I really know nothing about the OpenShift but typically no. A traditional web app will use something like nginx to route any requests for the domain to the appropriate port that meteor is running on. Only port 80 or 443 (ssl) need to be open to the world.

I’m assuming OpenShift start meteor for you. That’s pretty much the impression I’m left with from reading the guide you linked - ie it should specify if you have to start meteor and usually that would involve configuring some sort of start up script and not manually from a command line.

1 Like

I wrote a little utility to see if I could get a DDP connection to your server. No joy unfortunately.

Thank you Peter. I have found the following that I am trying now:

ps. Do you know what the following means?

Check if the execution flag is set for scripts located inside the given folders:

.openshift\action_hooks 
.openshift\lib

No sorry. Never used OpenShift.

If they’ve got forums it might be worth posting there. Or raising an issue as a question on that github guide you were following.

1 Like

Hi Peter,

I just deployed my Meteor App to OpenShift. From the logs below, it looks successful.

remote: Initiating MeteorShim
remote: Starting NodeJS cartridge
remote: *********** Meteor Environment ************
remote: MONGO_URL IS: mongodb://127.10.247.2:27017/
remote: ROOT_URL IS: http://mynodeapp-easyjobs.rhcloud.com
remote: PORT: 8080
remote: BIND_IP: 127.10.247.1
remote: DDP_URL: http://mynodeapp-easyjobs.rhcloud.com:8000
remote: ************ Starting NodeJS 0.10.40 SERVER  ************
remote: Thu Sep 08 2016 09:43:15 GMT-0400 (EDT): Node server started on 127.10.247.1:8080 ...
remote: Application is already running
remote:
remote:   - Using Node.js version 0.10.40, checking app URI ...
remote:   - test URI = http://mynodeapp-easyjobs.rhcloud.com/env
remote: -------------------------
remote: Git Post-Receive Result: success
remote: Activation status: success
remote: Deployment completed with status: success

When I configure my mobile app to the following, I get the errors below:.

http://mynodeapp-easyjobs.rhcloud.com:3000/ (timeout)
http://mynodeapp-easyjobs.rhcloud.com:8080/ (timeout)
http://mynodeapp-easyjobs.rhcloud.com:8000/ (404)

I know you said that it won’t be accessible on port 3000, but the Ionic App I have is trying to access it on http://mynodeapp-easyjobs.rhcloud.com:3000. (I changed it from the default http://localhost:3000 which works).

Question
However, I am not sure how to test if Meteor is running. How do I check if it is running?

Thanks

I’m using this which shows success (on port 80) when I connect to a couple of different meteor servers that I’ve got running.

It needs to be run with Chrome in insecure mode due to the Cross-Origin requests (on my linux machine I start it with google-chrome --args --disable-web-security --user-data-dir)

I can’t get it to connect to your server no matter what port I try. However I can now get to your server via the url in the browser. It has a link to this page which says the DDP url is http://mynodeapp-easyjobs.rhcloud.com:8000.

It’s 2am here and I’ve got a big day with work in the morning so I’ll probably be offline for the next 36 hours.

Hope you have better luck with it today.

1 Like

Thank you, the testing tool is very useful.