0
votes

I'm writing a custom build pack for Cloud Foundry to run a third-party application over which I have no control. This application (C/C++) executes code defined in metadata (configuration). It also hosts a JRE so that it can interact with Java code. The application does not communicate over HTTP. It instead uses a proprietary protocol to send messages to it.

To utilize Cloud Foundry's routing and elastic scaling, I'm writing a Java web application whose purpose is to:

  • Listen on $PORT for incoming HTTP requests
  • Forward HTTP requests to the application using its protocol

I understand that it's not best practice to execute multiple processes within a container, but, is there a way of specifying multiple commands to execute in parallel and have Cloud Foundry:

  • Forward each process's output
  • Monitor if any child process dies and restarts the whole container if it happens
  • Gracefully shuts down all the processes when scaling down/stopping/restarting, etc.
1
What about writing your own lightweight server that does that? By "forward each process's output" do you mean "proxy each process's responses"? If a child shuts down, the server can just shut itself down, and then Cloud Foundry will restart the app instance. Gracefully shutting down should just require trapping signals and sending them to the child processes. - Amit Kumar Gupta
Yes. It is something that I considered. Maybe even creating the process out of something like Jetty. Hosting the web app and the third party app. I was just wondering if there was something out of the box. - iggymoran

1 Answers

0
votes

Here is a simple reverse proxy in Go. http://www.darul.io/post/2015-07-22_go-lang-simple-reverse-proxy.

Go is easy, if you already know C or C++. The code is straight forward and Cloud Foundry comes with Go buildpacks. It will make it a lot easier to run in Cloud Foundry.

Give it a try.