Recently I have come a cross a situation where I wanted to up 3 different ruby web applications at once on the CentOS server which uses the Sinatra. When I was trying to run the first application by running the ./application1.rb, I was able to access the service in the 4567 port. While it was running I tried the second application by running ./application2.rb command. Then it gave the error regarding the port is already in used.
So that is acceptable. Because we all know the same port can not listen to two different applications at the same time. And according to my requirement I needed to run different ruby applications at the same time. So my target was to separately define different ports to each. So that I can use them without any interruptions. So how I achieved that?? I searched the web for the required details.
The very first thing I wanted to find out was, where these default configuration details come from. So I got the result.
The default Sinatra configuration details are put in the base.rb file. Once I checked that I have found out that the default port was set as 4567 as shown in the following figure.
So I have checked the application1.rb file and added a new line to change the default port to a port I preferred as follows.
"set:port, 4568"
That is to overwrite the default ruby listening port by introducing custom port number. And I checked the output by running the application1.rb file. Yay !! :D. It was running with the port I have defined. So I added different ports to other files as well. And now all the services are up and running in the ports I wanted. :) Hope this will help for someone else too !!! :)
"set:port, 4568"
That is to overwrite the default ruby listening port by introducing custom port number. And I checked the output by running the application1.rb file. Yay !! :D. It was running with the port I have defined. So I added different ports to other files as well. And now all the services are up and running in the ports I wanted. :) Hope this will help for someone else too !!! :)
Cheers!
"do good and good will come to you!"'
No comments:
Post a Comment