Open Food Network on new VPS – SVWH.HOST

Really liking Ben and Eric at

Once they had created the Ubuntu 14 instance, I installed nginx, which was like two terminal commands:

sudo apt-get update
sudo apt-get install nginx

Then the nginx welcome page came up at with the IP address in the browser.

Thanks again, Digital Ocean. Configured Name Cheap, the registrar, to host the name servers and created three records.

A Record: @ -> ip address
CNAME staging ->
CNAME www. ->

Running the ansible script:

ansible-playbook install.yml -i staging -vvvv

Stopped almost immediately. Couldn’t connect to server.

That’s ’cause port 22 isn’t enabled on the server. So in the staging file I had to add the ansible_port variable, as specified here.

After I created the user, ubuntu, I had to give it sudo with no password priviledges.

Then all of the deployment tasks ran successfully!

Had some struggle with SSL this time, but, encourage by this OFN post, had success with Let’s Encrypt. This is my sites_enabled nginx config file.

Delayed job script was running. Mails kind of slow. Next issues the Angular.js scripts are getting a 904 error and nothing from the assets directory is accessible.


service unicorn_openfoodnetwork stop
bundle exec rake assets:precompile:primary RAILS_GROUPS=assets RAILS_ENV=staging
bundle exec rake assets:precompile:nondigest RAILS_GROUPS=assets RAILS_ENV=staging
service unicorn_openfoodnetwork start

Though about running rake db prepare, but was getting postgres permissions issue ’cause the database was in use. Came across this cool post on seeing what processes are interacting with postgres.

Could it be that Root path is incorrect in nginx config?

Used this code find /rails/app/path -type l -exec ls -lad {} \; to see if there was a link pointing to the nginx public directory that I wasn’t seeing.

Stack overflow?

Back again after a few days on other things. Read through the Rails Asset Pipeline docs. Ran the above prcompile tasks again, with the --trace flag.

Output of –trace isn’t very insightful:

** Invoke assets:precompile:primary (first_time)
** Invoke assets:cache:clean (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Execute assets:cache:clean
** Execute assets:precompile:primary
openfoodnetwork@vps-64-62-148-34:~/apps/openfoodnetwork/current$ bundle exec rake assets:precompile:nondigest RAILS_GROUPS=assets RAILS_ENV=staging --trace
** Invoke assets:precompile:nondigest (first_time)
** Invoke assets:cache:clean (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Execute assets:cache:clean
** Execute assets:precompile:nondigest

Looks like this 904 error is on the url: And that URL is giving me a 502 bad gateway error! Nginx logs…

2016/05/24 21:08:54 [error] 2498#0: *950 connect() to unix:/home/openfoodnetwork/apps/openfoodnetwork/shared/sock/unicorn.openfoodnetwork.sock failed (111: Connection refused) while connecting to upstream, client:, server:, request: "GET /enterprises/check_permalink?permalink=pensacola-raw-cheese-and-aged-delights HTTP/1.1", upstream: "http://unix:/home/openfoodnetwork/apps/openfoodnetwork/shared/sock/unicorn.openfoodnetwork.sock:/enterprises/check_permalink?permalink=pensacola-raw-cheese-and-aged-delights", host: ""

Did I simply forget to restart the server via unicorn? OK. That was that error. Now when I wget the response is

--2016-05-24 21:17:46--
Resolving (
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 409 Conflict
2016-05-24 21:17:46 ERROR 409: Conflict.

What the fuck is a 409 conflict? Fuck. Let’s look at that check_permalink method. I understand now that the basic Rails framework configuration puts the final two elements of a URL string as a controller (basically a Class) and one of it’s methods. Lo and be-fucking-hold. The first line of the get_permalink function returns a 409 if “Enterprise.find_by_permalink params[:permalink]“. Whatever that is supposed to mean. I’m thinking it’s possible that the page content not being rendered isn’t related to this, but let’s see what happens if we comment out that first return statement…

Hey! Apparently one of the developers, who from what I hear is a very eclectic individual if Elf-Pavlic is the person I’m thinking of, has tracked down the issue and issued a pull request to the github repository. I hadn’t actually ever checked out a specific PR before.

At first I tried to do git fetch origin pull/1012/head:master and got the error fatal: Refusing to fetch into current branch refs/heads/master of non-bare repository because I was on the master branch. But once I had checked out the iLLHacks branch it ran beautifully, pulling in about 5 files. Fun.

Still getting that 409 issue. Seeing a 404 on the add new shipping method page:
NetworkError: 404 Not Found - again:
"NetworkError: 404 Not Found -"

Seems like the i10n isn’t quite working either because I’m seeing a lot of what look like placeholders: welcome_to_ofn, label_signup, label_login, forgot_password, signup_email, choose_password, confirm_password, etc throughout the site.

More 404s:
400 Bad Request –’datepicker/cal.gif’%20%%3E”

UPDATE: The issue was that translation/localization had not occurred when javascript files were rendered. Correcting any misconfigurations with which l10n file I was using, followed by completely removing the public/assets directory and regenerating with the above rake commands solved the issue with missing files and 409 errors.