flipkart-incubator / phantom

Phantom is a high performance proxy for accessing distributed services. It is an RPC system with support for different transports and protocols. Phantom is inspired by Twitter Finagle clients and builds on the capabilities of technologies like Netty, Unix Domain Sockets, Netflix Hystrix and Spring. Phantom proxies have been used to serve several hundred million API calls in production deployments at Flipkart.
50 stars 27 forks source link

Feature request: Provide sample including packaging #46

Closed MichaelF25 closed 9 years ago

MichaelF25 commented 9 years ago

Hi,

could you please provide (or enhance the existing) sample creating a complete package (tar.gz or zip) for a thrift proxy? Tried to do it by myself but without look.

Thx, Michael

regunathb commented 9 years ago

Micheal,

I need to understand this request better. So please help me with the following questions:

MichaelF25 commented 9 years ago

Based on the thrift sample I've already created a maven project providing a thrift proxy for my service which runs fine if started from project root as described in the sample: java -cp "./target/*:./target/lib/*" \ org.trpr.platform.runtime.impl.bootstrap.BootstrapLauncher \ ./src/main/resources/external/bootstrap.xml

Usually I am using Spring Boot and therefore I am used to have a single executable jar for my application. Since Phantom/Trooper works different, I wanted to create a suitable distribution .tar.gz / .zip for deploying the proxy application.

Based on the thrift proxy sample I would like to see how to use the maven assembly plugin which would create such a packaged distribution including a suitable start script.

regunathb commented 9 years ago

You are right in your observation that Phantom/Trooper does not run well with an uber jar. This is because of various reasons including having the editable configurations outside the jar. We package Phantom deployments as .deb packages here at Flipkart. Just curious - are you facing issues in just packaging all of the binary jars under "target" and "/src/main/resources/external" into a tar package? Basically you need binaries (jar files under target) and config files (under /resources/external of your module) to be part of the package. If it helps, I can share the startup script we use to bring up Phantom.

MichaelF25 commented 9 years ago

Yes, an example layout including start script of a packaged project would be helpful. For example I've also tried to start inside the target folder my proxy app with this command line:

java -cp "./*:./lib/*" org.trpr.platform.runtime.impl.bootstrap.BootstrapLauncher ./classes/external/bootstrap.xml

Trooper starts but the xml config files (logback, spring bean definitions) are not found and therefore not loaded.

regunathb commented 9 years ago

While I get you the sample layout and startup script, let me also clarify something about how Trooper finds config files. Trooper can find any deployed file so long as it resides under a relative path of /resources/external (sort of convention like WEB-INF/lib for web archives). The root path from which this search occurs is called the 'projectsRoot' - this is defined in bootstrap.xml that you use to start your Trooper instance. If you see your file, this property refers to something like "$RUNTIME_CONFIG_PATH/../../../../" - here $RUNTIME_CONFIG_PATH is replaced with the absolute path of the bootstrap.xml that you are using i.e. in your case ./classes/external/ and depending in the backtracking ("../") that is added, the final project root is arrived at. Trooper will scan all "/resources/external" paths from this resolved project root while looking for files.

Sorry that this is not obvious at all currently. Maybe we will add a FAQ section where issues like this are explained. Can you try re-looking at where you have deployed your logback, spring bean definitions files and also at the 'projectsRoot' property value you are using?

MichaelF25 commented 9 years ago

Thank you for the clarification about the /resources/external directory. This was the last missing piece which prevented my maven assembly from working. Everything works now fine - my maven project creates a .tar.gz including startup script which just needs to be unpacked and started for deployment.

regunathb commented 9 years ago

Michael,

Notes on our build, deployment and startup artifacts for Phantom based runtimes:

regunathb commented 9 years ago

Great to see that you are now able to get it to work. Can you please close this issue if you consider it resolved?