Running foodsoft in production

Hi everyone!

I’d like to get foodsoft running on my server (Debian 7).
The readme on github pointed me to this mailing list, so… here I am and
would be really glad about some help! :slight_smile:

Cheers,
Martin

Hi Martin,

Nice!

If you just want to play around with foodsoft, you can setup a
development instance as explained in doc/SETUP_DEVELOPMENT.md [1]. When
you want to share this installation with others, you can run the
production environment (set RAILS_ENV=production and review
config/environments/production.rb).

If you want to immediately run on a more solid deployment environment,
you can use passenger [5] or setup a reverse proxy.
http://rubyonrails.org/deploy has some pointers. This is basically the
same as setting up a development environment and then running the
production environment.

If you’re experienced with rails deployment, you may want to automate
deployment on a (remote) server. There are capistrano tasks shipped with
foodsoft. See [2] [2b].

In case you’d prefer to run on Heroku, the heroku deployment script [3]
would be of help.

I’m also working on a virtual machine image with foodsoft that’s
ready-to-run, but that’s not completely finished yet. If you’re
interested, I could upload an image somewhere. See [4].

Hope this provides some pointers to get started! Please feel free to ask
more specific questions on the mailing-list if you need more help.

Best,

  • Willem

[1]
https://github.com/foodcoops/foodsoft/blob/master/doc/SETUP_DEVELOPMENT.md
[2] https://github.com/foodcoops/foodsoft/blob/master/doc/DEPLOYMENT.md
[2b] https://github.com/foodcoops/foodsoft/tree/master/lib/capistrano/tasks
[3] https://github.com/foodcoops/foodsoft/blob/master/script/heroku_deploy
[4] https://github.com/foodcoops/turnkeylinux-foodsoft
[5] https://www.phusionpassenger.com/install_debian

Hi Willem!

Thanks a lot for your answer! :slight_smile:

I managed to get something running with Apache and Passenger, but I’m not completely sure if I did it correctly or if I forgot something maybe…

I set up the development environment with the rake task (foodsoft:setup_development), which worked in the »RailsEnv development« configuration, but not in production mode, for two reasons:
First, Apache wasn’t serving the static assets, so I configured Rails to do this in config/environments/production.rb — I don’t know if that’s what you’re supposed to do in a production system?
Second, I didn’t find a rake task or something to initialize the foodsoft_production database, so I just copied everything from foodsoft_development. Is that okay?

Is there anything else (cronjobs maybe, …?) I need to take care of?

Cheers,
Martin

HI Martin,

Good to hear you’re getting goin!

It’s true that the production environment needs something more.

  • Setting up the production database: you can use rake db:setup just
    the same. For the production environment, make sure that you set the
    environment variable RAILS_ENV=production, e.g. run
    RAILS_ENV=production rake db:setup or rake db:setup RAILS_ENV=production (as you can also give it as a rake parameter,
    iirc).
    But it’s perfectly fine to copy the database yourself from the
    development environment, like you did.
  • In production mode Apache can serve assets directly. That’s why
    asset serving is disabled in the production environment
    configuration. You do need to /precompile/ the assets, though.
    That’s done by a rake task RAILS_ENV=production rake assets:precompile. This gathers all javascripts and stylesheets,
    compresses them, and stores them in the public directory so that
    Apache can find them. You need to do this everytime the assets have
    changed.
  • Make sure to start resque workers at boot. See sample init script
    [1] (check it runs the correct environment, though).
  • For scheduled tasks you’d need a cronjob. I haven’t done this yet.
    You can also use the whenever gem’s functionality, see
    config/schedule.rb.

Cheers,

  • Willem

[1]
https://github.com/foodcoops/turnkeylinux-foodsoft/blob/master/overlay/etc/init.d/foodsoft-workers

Hi Willem!

Wow, that was… fast. :smiley:

In production mode Apache can serve assets directly. That’s why asset
serving is disabled in the production environment configuration. You
do need to precompile the assets, though. That’s done by a rake task
RAILS_ENV=production rake assets:precompile. This gathers all
javascripts and stylesheets, compresses them, and stores them in
the public directory so that Apache can find them. You need to do
this everytime the assets have changed.
Okay, the problem was the Apache configuration. I added an Alias for the assets directory, and now it’s working – except for the fontawesome files.
I have Apache configured to run foodsoft on /foodsoft and not /, but foodsoft tries to load the fontawesome-webfont.* files from /assets instead of /foodsoft/assets.
Apparently the problem is that asset-url in bootstrap_and_overrides.css.less (e.g. »@fontAwesomeWoffPath: asset-url(‘fontawesome-webfont.woff’);«) resolves to the wrong path, but I couldn’t figure out how to configure that correctly…

Make sure to start resque workers at boot.
Done. The sample init.d script was really helpful. :slight_smile:
(I changed it a bit to source rvm explicitly, because somehow it insisted on using the wrong Ruby version otherwise.)

For scheduled tasks you’d need a cronjob.
Okay, I don’t think we’re going to need scheduled tasks for now.

Best,
Martin

Hi Martin,

Good to hear you’ve got it running!

I remember seeing a similar problem with the fontawesome url when using
a suburi. You’re welcome to open an issue, I hope we can solve it at
some point.

Looking forward to hear how it’s going :slight_smile:

Cheers,

  • Willem

I remember seeing a similar problem with the fontawesome url when using a suburi. You’re welcome to open an issue, I hope we can solve it at some point.
Okay, I’ll do that.

And thanks again for all your help! :slight_smile:

Cheers,
Martin

This would be a great help.
Where should I send the ftp credentials to?

willem@foodcoop.nl

Please note that there will be an official foodsoft virtual machine
image as part of the TurnKey Linux project in the next release. The
image I’ll upload should work, but I’m still working on some details.