Search code examples
javascriptnode.jsexpressherokucodeship

How can I get Codeship to pass the check_url phase of a nodejs expressjs deployment on Heroku?


So in a nutshell I am trying to: Deploy - https://expressjs.com/en/starter/hello-world.html through Codeship and from Codeship to Heroku.

I have been trying to follow the very basic Hello-World express tutorial from https://expressjs.com/en/starter/hello-world.html but then the codeship check_url phase fails to load properly over Heroku getting the following error:

    Connecting to intfdsf-dsfdfsdf-323423.herokuapp.com (intfdsf-dsfdfsdf-323423.herokuapp.com)|54.243.89.187|:80... connected.
    HTTP request sent, awaiting response... 503 Service Unavailable
    2016-07-22 02:18:12 ERROR 503: Service Unavailable.

Under the Setup Command I have tried the following:

    nvm install 0.10
    nvm use 0.10
    npm install

and

    nvm install 6.3.0
    nvm use 6.3.0
    npm install

Both have failed the same way.

And adding something like npm start hangs the process on that line....

I have added a Procfile with web: node server.js and so renamed app.js to server.js just in case and for best practices. And finally I do have engines defined in my package.json as such:

    {
        "name": "node-ship",
        "version": "1.0.0",
        "description": "",
        "main": "server.js",
        "engines": {
            "node": "5.6.x",
            "npm": "3.10.x"
        },
        "scripts": {
            "start" : "node server.js",
            "test": "echo \"Error: no test specified\" && exit 1"
        },
        "repository": {
            "type": "git",
            "url": "git+https://github.com/slfkjsdlfjklsdkfj/node-ship.git"
        },
        "author": "slfkjsdlfjklsdkfj",
        "license": "ISC",
        "bugs": {
            "url": "https://github.com/slfkjsdlfjklsdkfj/node-ship/issues"
        },
        "homepage": "https://github.com/slfkjsdlfjklsdkfj/node-ship#readme",
        "dependencies": {
            "express": "^4.14.0"
        }
    }

What am I missing? So that I can get Heroku to load properly expressjs just like it loads locally when I run node app.js

Thank you for your help.

Here is the server.js file also:

    var express = require('express');
    var app = express();

    app.get('/', function (req, res) {
        res.send('Hello World!');
    });

    app.listen(5000, function () {
        console.log('Example app listening on port 5000!');
    });

Solution

  • The check_url script run by Codeship at the end of the Heroku deployment uses wget to check the status code of the root URL of your Heroku application. (If you want to check a different URL, there is a setting hidden behind the More Options link).

    As long as that page returns a status code in the 2xx or 3xx range the check will succeed.

    See https://github.com/codeship/scripts/blob/master/utilities/check_url.sh for the full script.