node.jslinuxsystemddirectus

Why is systemd service giving an error on start


I have created a new systemd service and keep getting an error when the service is started and Im not sure what could be up.

/usr/bin/env: node: No such file or directory
systemd[1]: test-panel.service: main process exited, code=exited, status=127/n/a

Here is my service file

[Unit]
Description=Test Panel
After=network.target
[Service]
User=root
WorkingDirectory=/var/test/panel/
ExecStart=/root/.nvm/versions/node/v16.6.1/bin/npx directus start
Restart=always
RestartSec=500ms
StartLimitInterval=0
[Install]
WantedBy=multi-user.target

I have other services that run just fine when the ExecStart is node with a script. Also when im in the active directory and call npx directus start manually, everything works fine.


Solution

  • I ended up changing around how I started Directus by adjusting ExecStart.

    ExecStart=/root/.nvm/versions/node/v16.6.1/bin/node node_modules/directus/dist/start.js
    

    This starts the service just like it should and I havent run into any downsides yet.