447

professional dilettante

Multiple Sinatra Apps with Nginx and Thin on Webfaction

I’ve been working on a Sinatra app to serve as a web development portfolio. I decided it is time to put it online using my shared host, Webfaction. Here in this post, I’m not going to go over all the steps to set up a Sinatra app. You can find my tutorial on that here: [...]

I’ve been working on a Sinatra app to serve as a web development portfolio. I decided it is time to put it online using my shared host, Webfaction. Here in this post, I’m not going to go over all the steps to set up a Sinatra app. You can find my tutorial on that here: Sinatra on Webfaction.

However, here I just wanted to discuss how I added a second Sinatra app on Webfaction. As a sys admin noob, it was not immediately obvious to me. After some thinking, I realized I could use my existing Nginx custom app. As I said… admittedly a noob.

And so the steps became:

Open a port for running Thin by creating a custom app in the webfaction control panel.
Make a custom app (“Custom app listening on port”) in the webfaction control panel. Name this app whatever your Sinatra app will be called. This app will show up in ~/webapps/APP_NAME.

Choose a domain/URL and add it to your existing Site being served by the Nginx App.
In the webfaction control panel, under Sites, if you are adding a second Sinatra app, then you already have a site being served by Nginx. You just need to add the domain/url for your app to the existing Site that is running your first Sinatra app.

Modify your ~/webapps/nginx/conf/nginx.conf
Add a new upstream app_name { } block and another server { } block.

Restart Nginx

[ ~/webapps/nginx]$ ps -u zhannes
20052 ?        00:00:00 nginx
[ ~/webapps/nginx]$ kill 20052
[ ~/webapps/nginx]$ ./sbin/nginx 

Make Sinatra app, rackup file, and create a yml file for Thin to read
Start Thin

Be done and happy.

One Response

You can follow the comments for this article with the RSS 2.0 feed.

Great posts (both of them).
They helped me a lot.

Just out of curiosity: how do you deploy your code to webfaction?

1 Fabricio July 25, 2012 1:48 am

Leave a Reply

Required fields are marked with an asterisk (*), you may use these tags in your comment: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 

Spam protection by WP Captcha-Free

Most Recent Post

create a file from content on your clipboard

You’re on github or something, reading code. You need to add some code to your project. You could: curl or wget the file URL clone the repo, extract single file, move it on file system create the file, open an editor, and paste in the content save as Here’s a terminal command I like. From [...]

Categories

Content © professional dilettante
Proudly powered by WordPress
Theme designed by Artisan Themes

Entries (RSS)
Comments (RSS)

25 queries.
0.927 seconds.