View this site in English Ver este site em português

Tag sinatra

How to restart a rails or sinatra app on dreamhost

18 September, 22:14, by zehzinho Tags:

Hi guys, if you followed my last post about running sinatra on dreamhost, you may have gotten frustrated when you tried to update your code. Dreamhost just didn’t want to refresh it, right?

Well, in the past it seems that the process was quite exoteric. I’ve read you had to create some tmp/shutdown.txt file or something like that.

Well, looking at the dreamhost wiki about rails deployment, I found out that the process got simpler. All you have to do is:

$ killall -USR1 ruby1.8

If it doesn’t work (perhaps they’ve updated their ruby version), you should take a look at the running processes:

$ ps -e

ok? Enjoy

Deploying (the latest) Sinatra apps on Dreamhost

18 September, 22:13, by zehzinho Tags: ,

Today I decided that would run my Sinatra app on Dreamhost. Until today I had only run the app on localhost, via shotgun. After trying to deploy it on heroku, without success, I remembered I had a shared account at dreamhost and then, why not?

Ok, after some failures (no single tutorial worked) I finally managed to make it run. Assuming you already have a sinatra app working and configured it using bundler, here are the steps that worked for me:

$ mkdir ~/.gems $ mkdir ~/bin $ mkdir ~/lib
$ mkdir ~/src
$ cd ~/src
$ wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.7.tg
$ tar zxvf rubygems-1.8.7.tgz
$ cd rubygems-1.8.7 $ ruby setup.rb --prefix=$HOME

Then, added to my ~/.bash_profile:

export GEM_HOME="$HOME/.gem"
export GEM_PATH="$GEM_HOME"
export RUBYLIB="$HOME/lib:$RUBYLIB"
export PATH="$HOME/bin:$HOME/.gem/bin:$HOME/.gem/ruby/1.8/bin:
$HOME/usr/local/bin:$HOME/usr/bin:$PATH"

and then, back again to bash:

$ source ~/.bash_profile
$ gem install bundler
$ cd path_to_your_app
 Important! Your rack version must be “1.2.1″, so in your Gemfile you should have:
gem "rack", '1.2.1'

Now you can build you gems:

$ bundle install

Finally, your config.ru should also contain the following lines:

Gem.clear_paths
ENV['GEM_HOME'] = '/home/your_user/.gem'
ENV['GEM_PATH'] = '/home/your_user/.gem:/usr/lib/ruby/gems/1.8'
require 'rubygems'
require 'bundler'
Bundler.require
FileUtils.mkdir_p 'log' unless File.exists?('log')
log = File.new("log/sinatra.log", "a")
$stdout.reopen(log)
$stderr.reopen(log) disable :run, :reload
set :environment, :production
set :views, File.dirname(__FILE__) + '/views'
require 'app'
run Sinatra::Application
 And that’s it! I’m running the latest version of Sinatra (which today is 1.2.6) without problems \o/

If you run into problems, the two posts which helped me most were the following two:

Using Bundler for Sinatra Applications On A Shared Host

and

Sinatra on Dreamhost