What does the .service file contain?

I’m using my own thing, Arch, SQLite3, which is my own problem.

I’m able to get Ghost up and running, but not as a service. I want to know what the .service file looks like at /lib/systemd/system/ghost_${domain}.service, but I can’t find it anywhhere in the docs or searches. The best I could find anywhere was this.

I don’t mind writing my own .service file, but I want to be as close to canon as possible.

Please give me some normal contents of the Systemd file at /lib/systemd/system/ghost_${domain}.service.

Here you go:

I don’t use the canonical file myself. Instead a I use a Podman and a .container file, which gets converted to a .service file during boot that runs Ghost within a container via Podman.

So it’s not exactly what you asked for, but here’s what my file looks like at /etc/containers/systemd/ghost_some-domain-com.container:

# MANAGED BY ANSIBLE
[Unit]
Description=Ghost Blog for some-domain.com
After=mysql.service network-online.target

# Keys are sorted in alpha-order
[Container]
# The name structure is exactly like what Ghost would create
ContainerName=ghost_some-domain-com
Image=docker.io/ghost:5.94
Network=mysql.network
# Pick a value within 10.10.*.*.
IP=10.10.23.71
# Map the "node" user in the container with UID 1000 inside the container to custom host user.
#UIDMap=1000:1000
Volume=/data/some.domain.com/content:/var/lib/ghost/content:z
Volume=/data/hopi.domain.com/config.production.json:/var/lib/ghost/config.production.json:z
1 Like

That much is exactly what I wanted to find and couldn’t!

In this question, I asked about the .service file. That example from the ghost Git repo contains:

ExecStart=<%= ghost_exec_path %> run

But, I am still curious about the start and stop command. Let’s say that I have a ghost installation at: /srv/www/ghost/mydomain.tld/

What then would the value be for these two parameters:

ExecStart=
ExecStop=

If you’re using the Ghost CLI, it will be the path to the Ghost CLI executable. For example, /usr/local/bin/ghost

It needs more than that. Mine ended up being:

ExecStart=/usr/bin/ghost run --no-prompt -d /srv/www/ghost/domain.tld

It needs the run directive, and the -d directory flag to indicate where to start.

The start directive can be used instead of run if using the command line, but this created problems inside the .service file for ExecStart=. And, run was used in the stock file example.

You shouldn’t need to pass -d here because WorkingDirectory should be /srv/www/ghost/domain.tld.

I was telling you what ghost_exec_path is but I can see where I could have worded it better :sweat_smile:

You definitely don’t want to use ghost start because it’s responsible for telling systemd to start the service, so you’ll have a dependency loop.

1 Like

Okay, I can omit the -d flag and it works because of the WorkingDirectory= parameter.

I’m a SysAdmin, I’ll tell Systemd to start the service myself. That’s why I wanted to know the ExecStart= parameter for the file.

If I understand correctly then, using start in the ExecStart= line would basically tell Systemd to start Systemd, which is probably why start broke when I used that in the line.

1 Like

you can use
ExecStop=/usr/bin/node /usr/bin/ghost stop

… if you wish, but as far as I know it is not necessary since the ghost server will stop when receiving the SIGINT sent by systemd whenever the server is shutdown/restarted

1 Like

Getting this right solved another problem…