How to fix a broken ghost CMS systemd service?

Hey guys!

Hope you are doing great.

Lately I’ve been thinking about using Ghost instead of Wordpress for a blog. The editor is much faster compared to gutenberg and you know, ghost has auto image optimizations, integrated SEO and a bunch of really great features.

My issue however is probably my fault. I was changing some settings at config prod json, and after running a “ghost restart” the service doesn’t restart anymore:

If I try to run ghost setup linux-user systemd, this is what I receive:

I tried to fully delete the systemd service with these commands:

systemctl stop ghost_blog-speedyour-day
systemctl disable  ghost_blog-speedyour-day
rm /etc/systemd/system/ghost_blog-speedyour-day
rm /usr/lib/systemd/system/ghost_blog-speedyour-day
systemctl daemon-reload
systemctl reset-failed

But unfortunately, they didn’t help.

I’am able to start my block with “ghost run” but not with ghost start. The service “ghost_blog-speedyour-day” still exists.

If I try to enable it: systemctl enable ghost_blog-speedyour-day --now

I still can’t manage it with ghost cli.

Ghost doctor says this:


To be honest, I don’t understand much about systemd. Do you guys know any way to create the service again?

Thanks!

1 Like

Forgot to mention that, but the changes at the config file were related to mail. I just changed it from direct to smtp. I tried to return to direct, but no results. I think it’s unrelated with config file anyway since ghost doctor isn’t saying that it’s config fault

Welcome, @aquasp.

Have you tried ghost setup systemd again?

Can you confirm that Ghost was running before changing production.json.conf, and share the file with password etc. redacted.

1 Like

Hey, thanks for your reply!

It says that systemd setup was already done :disappointed:

This is my current:

  GNU nano 4.8                                                                                   config.production.json                                                                                              
{
  "url": "https://myblog.com",
  "server": {
    "port": 2368,
    "host": "127.0.0.1"
  },
  "database": {
    "client": "mysql",
    "connection": {
      "host": "localhost",
      "user": "ghost-462",
      "password": "mypass",
      "database": "public_html_prod"
    }
  },
"mail": {
  "transport": "direct"
  },
  "logging": {
    "transports": [
      "file",
      "stdout"
    ]
  },
  "process": "systemd",
  "paths": {
    "contentPath": "/home/blogspeed/public_html/content"
  }
}

Ok, I think I’m giving up about systemd lol hehehe, always hated him…

Either way, if you have a issue like me and can’t fix systemd, just change to local:

ghost config --process local
ghost restart

Easier, simpler and more stable IMO. Hope Ghost keeps supporting non systemd alternatives

@mjw I know that you are probably busy, bust just wanted to tag you to show the “solution” that I found hehe.

I found a even better solution!

ghost config --process local
ghost restart
ghost config --process systemd
ghost doctor
(now fix any warning that ghost doctor says)
ghost restart

It’s all good now!

I know this is an old post but I had this same thing happen and it was maddening. I eventually found the solution (for me) so I wanted to post it here as it’s what came up when I was searching.

This is specific to my own system: I added a new volume to my VM and moved all my sites to that volume. That seemed fine except that my systemd services for the ghost sites disappeared.

ghost doctor revealed no issues.

ghost setup linux-user systemd resulted in the message Systemd service has already been set up. Skipping Systemd setup.

I could re-enable the service by doing systemctl enable ghost_{site-name} but then after a reboot the service would be gone.

Looking in /etc/systemd/system I saw that the .service files for my Ghost sites were symlinks to files in my ghost installation. This is a perfectly reasonable thing to do, but systemd initializes before external volumes are mounted. Since that volume wasn’t mounted yet, those files were essentially empty, and nothing happened. Also, adding Requires= and After= lines to the .service file, the normal way to delay a service starting until after a volume is mounted, won’t work because the .service file itself appears as empty if the volume is not mounted.

I think there must be a way to tell systemd to wait to load that file but I don’t know what it is. (I’m looking at those .wants and .requires directories).

For the moment my fix is:

  1. Copy the actual .service files from{ghost_root}/system/files/ghost_{site-name}.service into /etc/systemd/system
  2. Call it a day.

Sure, if a Ghost version update changes those files the changes won’t be reflected. But I’m guessing that doesn’t get changed often. In the meantime I have time to look deeper into systemd for a better fix.