0

Is it possible to run multiple rails apps from inside one Cloud9 IDE project? For example, I have the following structure...

MyApp (C9 Project)

  • MyApp-API (Rails/Grape)
  • MyApp-Web (Rails)

When I run rails server -p $PORT -b $IP via terminal in C9 in the respective app directories (i.e., MyApp-API, MyApp-Web) they both appear to be running. However, when I do cURL requests or try browsing directly I am not able to reach routes as expected.

I assume it's because I'm running the rails servers with the same port/ip configurations.

xspydr
  • 3,030
  • 3
  • 31
  • 49

3 Answers3

0

only if you place API part in app/controllers/api/posts_controller.rb for example. And set route for it, for example as domain myapp.com/api/posts.json or subdomain (api.myapp.com/posts.json)

itsnikolay
  • 17,415
  • 4
  • 65
  • 64
  • That would make the two apps one app. I want to keep them separate. – xspydr Oct 01 '14 at 17:22
  • then you shoud run 2 separate process of web server(unicorn, puma and etc.) for each app, and configure nginx(apache) to handle url request to the app streams. – itsnikolay Oct 01 '14 at 17:24
  • My question more relates to how to achieve this using the Cloud9 IDE. I believe my configuration could be achieved without the need for another layer (i.e., unicorn, puma, etc) if C9 provides alternate debugging ports. – xspydr Oct 01 '14 at 17:28
  • Hi, we do not provide multiple exposed ports yet. My advice is to use a ssh server. Please keep in mind that the proposed solution with a subdomain will not work in C9. we only have 1 subdomain available for every workspace. The routing is still a good option. – lcipriani Oct 02 '14 at 08:53
0

Looks like this can't be done. C9 apparently only exposes one port. I will most likely need to break the apps out into separate projects...

How to use grunt serve in Cloud9 IDE?

Technically, I can run the API app on a different local port such as:

rails server -p 15001 -b $IP

Then I can connect to it with cURL requests or have the web app connect to it with that end point.

curl -X GET http://localhost:15001

It's a bit of a pain but, at least there is a workaround.

Community
  • 1
  • 1
xspydr
  • 3,030
  • 3
  • 31
  • 49
0

Cloud9 does not (yet) expose multiple ports to the outside. One approach that could work is to put a small reverse proxy like HAProxy or Nginx in front of you apps. You can run your different apps on arbitrary ports and let the proxy listen on $PORT. Then configure the proxy to forward to yours apps e.g. based on the path.

Fabian Jakobs
  • 28,815
  • 8
  • 42
  • 39
  • Thanks, I ultimately decided just ended up splitting the apps out into two separate projects. – xspydr Oct 02 '14 at 13:16
  • Could you please explain more in detail? I am facing the same issue than Jason and i am not sure on how to install/configure ngix to proxy the request for the api on a different port (ex 15001) ? – Doum Jan 08 '15 at 15:35