Skip to content

Latest commit

 

History

History
52 lines (37 loc) · 1.31 KB

File metadata and controls

52 lines (37 loc) · 1.31 KB

To create a Linux service that runs a the worker script, you can use a systemd unit file. First, create a systemd service configuration file, and then start and enable the service using the systemctl command.

Follow these steps:

  1. Create a new service file for your Node.js script.
sudo nano /etc/systemd/system/dlaas.service
  1. Add the following content to the service file, replacing /path/to/your-worker-script.js with the actual path to your Node.js script:
[Unit]
Description=DLaaS Worker Service
After=network.target

[Service]
ExecStart=/usr/bin/node /path/to/your-worker-script.js
Restart=always
User=nobody
Group=nogroup
Environment=PATH=/usr/bin:/usr/local/bin
Environment=NODE_ENV=production
WorkingDirectory=/path/to/your-worker-script

[Install]
WantedBy=multi-user.target
  1. Save the file and exit the text editor.

  2. Reload the systemd daemon to apply the new service configuration:

sudo systemctl daemon-reload
  1. Enable and start the service:
sudo systemctl enable dlaas.service
sudo systemctl start dlaas.service
  1. Check the status of your service:
sudo systemctl status dlaas.service

Your DLaaS worker script should now be running as a Linux service. The service will automatically restart if the script crashes or if the system is rebooted.