Running a second ghost service fails at running CHDIR /usr/bin/npm, finding no directory?

December 16, 2016 141 views
Ghost Node.js Nginx Ubuntu 16.04

I've been configuring my Ubuntu 16.04 droplet to run two ghosts blogs on two separate nginx server blocks. I've got the second ngnix server block running correctly and the second domain is pointing to the correct port and not the first server block. However I am getting a 502 error indicating Ghost isn't running for that domain.

I've run a status check and here is the output from service ghost 2 status

ghost2.service: Failed at step CHDIR spawning /usr/bin/npm: No such file or directory
ghost2.service: Main process exited, code=exited, status 200/CHDIR
ghost2.service: Failed at step CHDIR spawning /usr/bin/npm: No such file or directory
ghost2.service: Control process exited, code exited=status=200
ghost2.service: Unit entered failed state.
ghost2.service: Failed with result 'exit-code'.
ghost2.service: Service hold-off time over, scheduling restart.
Stopped ghost
ghost2.service: Start request repeated too quickly.
Failed to start ghost.

The first ghost service runs fine using the same /usr/bin/npm directory in the start up script. However, the directory doesn't seem to exist.

I'm wondering what the issue might be and how I can get the second instance of ghost running.

1 Answer

This is a bit confusing. I would recommend double-checking your configuration. A CHDIR to /usr/bin/npm would be likely to fail as npm is a binary, not a folder. Can you share the steps you took in setting up the second site?

  • I've followed the instructions in this article here https://cloud.digitalocean.com/support/suggestions?article=how-to-serve-multiple-ghost-blogs-on-one-vps-using-nginx-server-blocks&i=d0a07c&page=0&query=ghost%20two%20blogs

    Making adjustments as necessary for Ubuntu 16.04, such as making the start-up script using systemd instead of upstart and also creating the second Ghost blog server block in the sites-available folder and sym linking it to the sites-enabled folder.

    Before I was having trouble with nginx server blocks, but that's no longer the issue as the second domain no longer directs to the same port as the first domain.

    I then followed the instructions there in copying the ghost directory in the /var/www/ folder and setting up the ghost config to run on the correct port and with the right directory.

    The issue I am having is in setting up the systemd file to allow the second ghost service to run correctly and serve the second ghost blog.

    This is the current config I have on the systemd file, it's essentially the same way the default ghost which is like this:

    [Unit]
    Description=ghost

    [Service]
    Type=simple
    Working Directory=/var/www/ghost

    ExecStart=/usr/bin/npm start --production
    ExecStop=/usr/bin/npm stop --production
    Restart=always
    SysLogIdentifier=Ghost

    User=ghost
    Group=ghost
    ProtectSystem=full
    ProtectHome=yes
    PrivateTmp=yes
    PrivateDevices=yes

    [Install]
    WantedBy=mult-user.target

    And then the ghost2.service is set up in this way:

    [Unit]
    Description=ghost2

    [Service]
    Type=simple
    Working Directory=/var/www/secondghost

    ExecStart=/usr/bin/npm start --production
    ExecStop=/usr/bin/npm stop --production
    Restart=always
    SysLogIdentifier=Ghost

    User=ghost
    Group=ghost
    ProtectSystem=full
    ProtectHome=yes
    PrivateTmp=yes
    PrivateDevices=yes

    [Install]
    WantedBy=mult-user.target

    The first instance of Ghost runs fine with no issues and when running 'service ghost status' it returns that everything is fine and running.

    When running a status check on ghost2.service it give me the output that I had in the original post. And I am told that /usr/bin/npm is not a directory when checking for it manually.

    I'm not sure what I need to do to get both services to run.

Have another answer? Share your knowledge.