Documentation

Deployment

Run API (as Service)

You need your API to run as a service so it starts automatically on boot and survives restarts. Here's how to set it up using systemd on Ubuntu:

sudo nano /etc/systemd/system/shipdotnet-api.service
[Unit]
Description=ShipDotnet Api

[Service]
WorkingDirectory=/var/www/apps/shipdotnet-api
ExecStart=/var/www/apps/shipdotnet-api/ShipDotnet.Api
Restart=always
RestartSec=10
KillSignal=SIGINT
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

StandardOutput=append:/var/log/shipdotnet-api.log
StandardError=/var/log/shipdotnet-api.log

[Install]
WantedBy=multi-user.target

The log file we specified above need to be created manually:

sudo touch /var/log/shipdotnet-api.log

We also need to give www-data user permission to write to it:

sudo chown www-data:www-data /var/log/shipdotnet-api.log

Let's spin the service:

sudo systemctl enable shipdotnet-api.service
sudo systemctl start shipdotnet-api
sudo systemctl status shipdotnet-api

You should see this:

● shipdotnet-api.service - ShipDotnet Api
	Loaded: loaded (/etc/systemd/system/shipdotnet-api.service; enabled; preset: enabled)
	Active: active (running) since Fri 2025-06-06 17:19:33 UTC; 3s ago
	Main PID: 18113 (ShipDotnet.Api)
	Tasks: 15 (limit: 995)
	Memory: 40.1M (peak: 40.2M)
	CPU: 1.015s
	CGroup: /system.slice/shipdotnet-api.service
		└─18113 /var/www/apps/shipdotnet-api/ShipDotnet.Api

Now verify if your API is rolling:

curl http://localhost:5000
Hello there! I'm Obi-Wan Kenobi, and this is the API you're looking for.

If you need to view logs just hit:

tail /var/log/shipdotnet-api.log