Having read article on Habré about OpenShift , I immediately wanted to make friends with this platform. Still, a free remote computer with 512MB of RAM and 1GB of space will not be superfluous on the farm. ;) Especially since you can run not only the web server platform offered by the platform itself, but also something of your own. The choice fell on Tomcat with a small personal project.
Next, I will describe the algorithm for implementing this idea:
After authorization you are offered to choose the type of application ( Choose a type of application ), choose from the list the type of do-it-yourself
Set the Public URL and click Create Application
Hooray, the remote computer is waiting for us! It remains to reach him through ssh. At the bottom of the page we see the section Set your Public Key - you need to set the public key. I used public key generation via PuTTY . By sending the public key to the server, the ssh address will become available to us (something in the spirit of: ssh: // many-digit@your- app.rhcloud.com)
Now you can deploy your application!
2. What do they give?
At the beginning, I will say a few words about the remote machine we received:
Installed java 1.6.0_22
For the outside world, you can use port 8080, which, by default, is busy with a ruby-stub
For debug server, you can separately enable port 8787 (more on this below)
3. Start Tomcat
The main nuances of copying the server to a remote machine are described in this wonderful article . Therefore, we will assume that we have already copied Tomcat to the app-root / data / tomcat folder, configured ip and all the ports in the app-root / data / tomcat / conf / server.xml file (ip was received from $ OPENSHIFT_INTERNAL_IP, and the port values were set above 15000, except for port 8080) and now they are ready to start their server, but we are hampered by the already running ruby-stub on port 8080. And plus, we still have no possibility of debugging the server through port 8787. We will solve these difficulties:
It is time to install the OpenShift client tools . Unfortunately, without it, it will not be possible to solve all the problems that have been voiced.
After installing the client tools and running in the console, you will be prompted to generate an ssh key and save it to the server. Be sure to agree! Because Git will use this key, but nobody knows anything about PuTTY except your PuTTY key :)
So, we have client tools and Git, now we can turn off the ruby-stub. At the beginning, look at the article explaining the principle of starting and stopping applications via the Git repository . In a nutshell, the meaning is as follows: when you push to a remote computer, sh scripts from the .openshift / action_hooks folder are automatically called (this is relative to the repository, but the address on the remote machine: app-root / runtime / repo / .openshift / action_hooks ). These scripts are designed to stop the current web server, build and restart it. By default, a ruby stub is written in these sh files. The idea is to remove the .openshift / action_hooks / start script from the script, launch this stub and send the changes to the remote repository. Then the stub will be stopped by the .openshift / action_hooks / stop script and port 8080 will be free.
Actually we do everything that was said above: download the repository to your machine, edit the .openshift / action_hooks / start file, remove the ruby-stub from it, and send the changes to the server. As a result, we have released port 8080 and we can launch our Tomcat via PuTTY. No, of course, you can register starting and stopping tomkata in .openshift / action_hooks files , but I was not interested - the ssh-console is somehow closer;)
Almost everything is ready. Tomcat is launched and accessible to the outside world. It remains only to solve the problem with debag. The solution lies in this article . In a nutshell, you need to create a new .openshift / markers / enable_jpda file and upload it to a remote repository. After that port 8787 will be open for our tomkata. But stop! After all, only port 8080 sticks out, how can you get to 8787?
To get access to ports other than 8080, you need to use client tools : we type in rhc-port-forward –a applicationName in our console and now all ports of the remote machine are accessible on the local machine (at the address in the spirit of 127.6.242.5)
4. Results
The Tomcat startup algorithm on OpenShift was rather dreary, but what you can’t do for the sake of a freebie. Have a nice work!