I am recently going through a ghost major version update with my Ubuntu 18 server and I keep running into an issue where the node version I use via nvm on the server is out of sync with the node version being run by systemctl when I run ghost update
.
In my server file, ghost_www-website-com.service
the ExecStart references the /usr/bin/node
path, which contains an old node version installed to the server when I first created it, but since then I have moved to use nvm to manage the node on the system.
I know I can change the path from usr/bin/node
to /home/ghost-mgr/.nvm/versions/node/v14.15.0/bin/node
to execute node from my nvm directory, but this isn’t helpful if I update to a new node version via nvm. Is there a way to have a dynamic path of the node version selected with nvm that systemctl understands?
ghost_www-website-com.service config:
[Service]
Type=simple
WorkingDirectory=/var/www/ghost
User=999
Environment="NODE_ENV=production"
ExecStart=/home/ghost-mgr/.nvm/versions/node/v14.17.0/bin/node /usr/bin/ghost run
Restart=always