In this tutorial, we will guide you through the process of creating a systemd service to ensure your application automatically starts after the system boots up. This is particularly useful for server setups, ensuring the continuous operation of your application.

👉 Linux: Systemd Service

Step 1: Open and Edit the Systemd Service File

1.1 Open the systemd service file using the following command:

sudo nano /etc/systemd/system/your.service

1.2 Once the file is open, add the following configuration:

Description=Dubly Backend

ExecStart=conda activate dub && gunicorn --bind


Save and exit the editor.

Step 2: Adjust Permissions for the Service File

Run the following command to set appropriate permissions for the service file:

sudo chmod 644 /etc/systemd/system/your.service

Step 3: Enable and Start the Systemd Service

3.1 Reload systemd to apply the changes:

sudo systemctl daemon-reload

3.2 Enable the newly created service to start on boot:

sudo systemctl enable your.service

3.3 Start the service for the current session:

sudo systemctl start your.service

Step 4: Check Service Status and Logs

To ensure everything is functioning as expected, you can check the status and logs of the systemd service:

sudo systemctl status your.service

Additionally, view the service logs:

journalctl -u your.service

Step 5: Test the Running Service

Verify that your application is accessible and operational:

curl -X POST localhost:5000/api/your-endpoint

Congratulations! You’ve successfully created a systemd service for your application, ensuring it starts automatically after system boot. Adjust the paths and configurations according to your specific setup and requirements.

👉 MacOS: Launchd Service

# Create the launchd service
cd path/to/where/you/want/
nano your.plist


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
<plist version="1.0">
cd backend
chmod 644 config/your.plist
launchctl load config/your.plist
launchctl start config/your.plist
launchctl list | grep your # Check Service Status
cat logs/yourapp.log
cat logs/yourapp.error.log
launchctl stop config/your.plist
launchctl unload config/your.plist

Written by

Albert Oplog

Hi, I'm Albert Oplog. I would humbly like to share my tech journey with people all around the world.