4

I have 2 Ghost blogs on a Digital Ocean server running:

  • Ubuntu 14.04.3 LTS
  • Nginx 1.4.6 (Ubuntu)
  • Node v0.12.7

I used the instructions provided by Digital Ocean to set up the blogs, and they have worked fine and survived upgrades before.

Last night, I upgraded blog #1 from Ghost v0.6.0 to 0.7.0 and experienced no problems. After upgrading I ran service ghost-{blog1} restart and it came online with pomp and triumph.

I immediately attempted to upgrade blog #2 following the same steps, but when I opened it in my browser after restarting the service, I got the "502 Bad Gateway" error.

I found that npm failed to install SQLite3 correctly, and fixed that. Now, I can start the blog successfully by running npm start --production. The terminal shows that Ghost is running and intercepting requests, and I can use the site and blogging app in my browser.

But when I run service ghost-{blog2} start, it continues to fail without presenting a terminal error. I get the following message:

ghost-{blog2} start/running, process 1693

But I still see the "502 Bad Gateway" error in my browser.

Edit: I changed my startup script to run npm start --production > ghost-{blog2}.log instead of npm start --production, and I can see that Ghost starts up, and then quits immediately without error:

> ghost@0.7.0 start /var/www/{blog2}/ghost
> node index

That's all that is in the log, even after hitting the page a few times. Nginx logs the requests, but Ghost doesn't.

By contrast, when I start the blog by running npm start --production > ghost-{blog2}.log from the terminal, the log continues thus:

> ghost@0.7.0 start /var/www/{blog2}/ghost
> node index

Migrations: Up to date at version 004
Ghost is running in production...
Your blog is now available on http://{blog2}
Ctrl+C to shut down
{{Requests}}

Can anyone suggest steps I can take to troubleshoot this?

Edit: Here are the relevant configuration details for each blog.

Blog #1: This is the one that works

/var/www/{blog1}/config.js

production: {
    url: 'http://{blog1}',
    mail: {},
    database: {
        client: 'sqlite3',
        connection: {
            filename: path.join(__dirname, '/content/data/ghost.db')
        },
        debug: false
    },

    server: {
        // Host to be passed to node's `net.Server#listen()`
        host: '127.0.0.1',
        // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
        port: '2369'
    }
},

/etc/nginx/sites-enabled/{blog1}

    server {
        listen 80;

        server_name {blog1};

        root /usr/share/nginx/html;
        index index.html index.htm;

        client_max_body_size 10G;

        location / {
            proxy_pass http://localhost:2369;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_buffering off;
        }
    }

/etc/init/ghost-{blog1}.conf

    # ghost-{blog1}

    start on startup

    script
        cd /var/www/{blog1}
        npm start --production
    end script

Blog #2: This one works when I start using npm start --production, but fails when I start as a service

/var/www/{blog2}/ghost/config.js

production: {
    url: 'http://{blog2}',
    mail: {},
    database: {
        client: 'sqlite3',
        connection: {
            filename: path.join(__dirname, '/content/data/ghost.db')
        },
        debug: false
    },

    server: {
        // Host to be passed to node's `net.Server#listen()`
        host: '127.0.0.1',
        // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
        port: '2777'
    }
},

/etc/nginx/sites-enabled/{blog2}

    server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        server_name {blog2};

        root /usr/share/nginx/html;
        index index.html index.htm;

        client_max_body_size 10G;

        location / {
            proxy_pass http://localhost:2777;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_buffering off;
        }
    }

/etc/init/ghost-{blog2}.conf

    # ghost-{blog2}

    start on startup

    script
        cd /var/www/{blog2}/ghost
        npm start --production > ghost-{blog2}.log
    end script
  • What are the config files of both blogs (with SMTP or DB credentials censored) ? – André Borie Sep 15 '15 at 8:43
  • Thank you, @AndréBorie—I've updated the post to include the relevant details. – John Stephens Sep 16 '15 at 17:09
1

I ended up removing node_modules for ghost and then reinstalled everything.

rm -rf node_modules && npm cache clean
npm install --production

Sqlite3 was not install properly, so I had to reinstall that as well. This deleted my database, but I had a backup.

npm install sqlite3

After restarting the services everything was working again.

service nginx restart && service ghost restart
  • Thanks for your report! I had to do this too, and like I said, for blog #1 it worked: I can run it via the service start command and the blog appears online without a hitch. Followed the same steps with blog #2 on the same server, and this does not fix the issue. – John Stephens Sep 8 '15 at 3:33
0

I finally solved this problem!

The answer was to downgrade Node.js to version 0.10.40. When I wrote the above, I was running node vv0.12.7.

Ghost's install documentation says it supports v0.12.x, but when looking at it again today, I noticed that it recommends v0.10.40.

It's not clear to me at all why this solves the problem, but I'll take it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.