Foodsoft deployment

Hey Guys,

I installed foodsoft on my server, but I did run into some trouble.
The test with ‘rails server’ did succeed.
But now I’m trying to run foodsoft in production mode with apache and mod-passenger and I get an error massage:
‘git://github.com/technoweenie/acts_as_versioned.git (at master) is not checked out. Please run bundle install (Bundler::GitError)’

The think is I did run bundle install and everything works fine with ‘rails server’.
So, what did I miss?
Is it the ruby environment, the mod-passenger, or foodsoft?

Many thanks in advance!
kaat0

Hi kaat0,

Welcome to the list!

We’re using mod-passenger with success, perhaps you find our deployment
notes useful
https://github.com/foodcoop-adam/foodsoft/wiki/Deployment

Do you use RVM?

  • Willem

Hey Willem,

thanks for the quick answer!

I wasn’t aware that RVM was necessary. So there might be the problem. I’ll go and figure it out.

I’m using a Debian wheezy system with SQLite. The ruby environment was install by apt-get and gems.
Thanks for pointing me to github.com/foodcoop-adam. I only searched in bennibu and the foodcoops repo wikis.

Greetings, kaat0

Hi kaat0,

It may not be necessary - it’s what we use.
I’d need to look a bit more to see what could be the problem without rvm.

  • Willem

Hey guys,

Let’s document the usage of RVM and preferably a link to how to set it up.
Should be possible for non-Ruby people to run the app, right?

(AFAIK there is already a ticket for this - will look at that tomorrow.)

Ciao,
Mathijs

kaat0 [via foodsoft] schreef:

Hey!

if necessary or not, I can’t tell …
Thing is, that via apt-get I will only get Ruby 1.9.1. So, at least I can get Ruby 1.9.3 via RVM.
And after pointing mod_passenger (/etc/apache2/mods-available/passenger.conf) to right Ruby environment (/usr/local/rvm/bin/ruby-1.9.3-p448) I get from apache:

‘Application error
Rails application failed to start properly’

Some kind of a progress. Something went wrong with my mod_passenger installation. Hope to fix it soon…

RVM is good practise for pretty much any deployment setup AFAIK. :slight_smile:

Step by Step…

It turns out, that it is a bad idea to use RVM and still install mod_passenger via apt-get. bad on me.

But, sorry, it is still not running. Now I get:

(2)No such file or directory: exec of ‘/srv/foodsoft/public/dispatch.cgi’ failed
Premature end of script headers: dispatch.cgi

The first line of dispatch.cgi is: #!/usr/bin/ruby1.8
I already know from Benni that you don’t use the dispatch.cgi anymore.

My /etc/apache2/sites-available/foodsoft is:
<VirtualHost *:80>
ServerName foodsoft.example.org
DocumentRoot /srv/foodsoft/public
<Directory /srv/foodsoft/public>
Allow from all
Options -MultiViews

ErrorLog /srv/foodsoftlog/error.log

What’s wrong? What and how to use something different then dispatch.cgi? :slight_smile:

Step by Step…

It turns out, that it is a bad idea to use RVM and still install
mod_passenger via apt-get. bad on me.
Oh, that’s a nuisance.

But, sorry, it is still not running. Now I get:

(2)No such file or directory: exec of
‘/srv/foodsoft/public/dispatch.cgi’ failed
Premature end of script headers: dispatch.cgi

The first line of dispatch.cgi is: #!/usr/bin/ruby1.8
I already know from Benni that you don’t use the dispatch.cgi anymore.

My /etc/apache2/sites-available/foodsoft is:
<VirtualHost *:80>
ServerName foodsoft.example.org
DocumentRoot /srv/foodsoft/public
<Directory /srv/foodsoft/public>
Allow from all
Options -MultiViews

ErrorLog /srv/foodsoftlog/error.log

What’s wrong? Waht and how to use something different then
dispatch.cgi? :slight_smile:
Yes, I’ve removed those files since they use features not present in
Rails 3 anymore.
Current practice is to use passenger with the Rack interface [1], which
looks at config.ru .

The other option with Apache would be fastcgi, but I haven’t got that to
work yet.
This might help a little (incl. suggestions for public/dispatch.fcgi)
ruby - Rails 3 and FCGI? - Stack Overflow
http://wiki.dreamhost.com/Rails_3
http://www.tummy.com/articles/rails-fcgi/

If you just want to get it running, I suggest to install Passenger and
RVM yourself.

Cheers,

  • Willem

[1]
http://www.modrails.com/documentation/Users%20guide%20Apache.html#_deploying_a_rack_based_ruby_application_including_rails_gt_3

If youre running this on dreamhost you have little chance without this:
http://blog.micahchalmer.net/blog/2012/dreamhost-shared-hosting-rbenv

Hi Angelo,

Welcome!
And thanks, I’ve added that to the newly created deployment notes.
https://github.com/foodcoops/foodsoft/wiki/Deployment-notes

Cheers,

  • Willem

Hello,

I am going to talk about shared servers and foodsoft.

I did try the heroku route as well multiple times during the summer. It did not work either. I definitely want to help develop eventually, but I am still at the beginning of understanding ruby on the rails framework. On the capistrano stuff I am completely lost. I have no idea what to do with it.

I think it is plausible that a large portion of the people who will be interested in using foodsoft will have access to a shared server through a service like Dreamhost (DH). That is to say, they are already paying for this, and probably do not want to make a practice of buying new hosting.

But running apps using ruby 1.9.3 on DH appears to only be possible through FastCGI. Their Passenger install uses rails 1.8.7, so it’s a “no go”. As was posted above, I have been trying to get this particular setup working since it is the only place on the internet where someone says they have 1.9.3 working on DH.

But deploying foodsoft to dreamhost even with these tools has been elusive. Before latest bunch of changes to the foodsoft git, I was at least getting some errors, but now I just get nothing.

There is some discrepancy as to where dispatch.fcgi should go. Micah Chalmer says it should go directly in /home/sampleuser/example.com while dreamhosts rails wiki says it should go in /public.

Here’s the quote from Micah:

“All the files below should go in your project root directory, which should also be configured as your web directory in the DreamHost panel. Usually that means if your site was example.com and your user was sampleuser then you’d be putting these files, along with your Rack app, into /home/sampleuser/example.com.”

So where should dispatch.fcgi go? Does it matter?

Hi,

Recently I’ve removed dispatch.fcgi, because it didn’t work anyway -
being left-over from Rails 2.
I guess you read
http://wiki.dreamhost.com/Rails_3
This also contains a sample dispatch.fcgi. I would say it goes into the
public directory - that’s where web-server accessible files go. It
doesn’t actually matter where the goes - as long as it can be served as
an fcgi file and dispatch.fcgi knows where to find foodsoft’s
installation directory (for environment.rb, I guess).

I’ll be happy to include dispatch.fcgi in foodsoft’s public directory,
when it actually works.

  • Willem

p.s. At this moment, Capistrano is probably untested.

Hi,

put dispatch.fcgi into /public and configure the vhost to use /public as your web directory.

Manuel

Right now I have my home server running and I have lafoodcoop.org pointing to it (on port 3000).

My up speed is 1mbps, which appears to be more than enough to serve one user at a time. Since there are only about 30 of us, maybe this could work until I get it working with Dreamhost. This way we have many more people generating errors, which may be a good thing for development.

Can I make development https protected?

The only error I saw was when I tried to save a wiki page:

undefined method `pages’ for #User:0x000000045a5330

Is this the kind of issue I would report in the github issues tab?

Hi Angelo,

Too bad it doesn’t work out yet. I think a home server would be ok to
start with.
I’d strongly advise to use a production setup - the default development
setup allows to run arbitrary code when an error occurs, for example.
Just use the production environment. You need to precompile your assets.
The typical steps for updating production would be:

  • git pull
  • bundle install (when Gemfile or Gemfile.lock was changed)
  • [only when using additional plugins] RAILS_ENV=production rake
    railties:install:migrations
  • RAILS_ENV=production rake db:migrate
  • RAILS_ENV=production rake assets:precompile
  • restart your webserver (with passenger: touch tmp/restart.txt)

Our deployment guide may be useful for you
https://github.com/foodcoop-adam/foodsoft/wiki/Deployment
Also explains how to setup ssl in production.

The issue is a valid one - yes, do feel free to use the bugtracker! I’ve
just fixed it on master, so don’t need to report this bug anymore.

  • Willem

And the easiest way would be to execute RAILS_ENV=production rails s so that the production settings are loaded. Remember to precompile the assets first, as described earlier too RAILS_ENV=production rake assets:precompile I’m curious to hear how your ordering cycle went, please feel free to share about that! - Willem