June 06, 2025
11 11 11 AM

Run Tradehook as Linux Service

Console

Creating a Systemd Service for Tradehook .NET Core Application

  1. Create Service File: Create a new service file in /etc/systemd/system/, named after Tradehook application (e.g., tradehook.service).
sudo nano   /etc/systemd/system/tradehook-console.service

[Unit]
Description=Stoxello Tradehook Console

[Service]
WorkingDirectory= /home/administrator/tradehook/console
ExecStart= /usr/bin/dotnet /home/administrator/tradehook/console/console.dll
Restart= always
RestartSec=60
KillSignal= SIGINT
SyslogIdentifier= tradehook-console
User=root
Environment= ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy= multi-user.target

Make sure to change directory path with your application directory.

2. Reload Systemd: After creating the service file, reload systemd to read the new service file.

sudo systemctl daemon-reload

3. Enable and Start Your Service: Enable your service to start on boot, and then start the service immediately.

sudo systemctl enable tradehook-console.service
sudo systemctl start tradehook-console.service

4. Monitoring and Managing the Service: Use systemd commands to manage and monitor your service.

  • Check Statussudo systemctl status tradehook-console.service
  • Restart Servicesudo systemctl restart tradehook-console.service
  • Stop Servicesudo systemctl stop tradehook-console.service

Proxy

sudo nano   /etc/systemd/system/tradehook-proxy.service

[Unit]
Description=Stoxello Tradehook Proxy

[Service]
WorkingDirectory= /home/administrator/tradehook/proxy
ExecStart= /usr/bin/dotnet /home/administrator/tradehook/proxy/proxy.dll
Restart= always
RestartSec=60
KillSignal= SIGINT
SyslogIdentifier= tradehook-proxy
User=root
Environment= ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy= multi-user.target

Make sure to change directory path with your application directory.

2. Reload Systemd: After creating the service file, reload systemd to read the new service file.

sudo systemctl daemon-reload

3. Enable and Start Your Service: Enable your service to start on boot, and then start the service immediately.

sudo systemctl enable tradehook-proxy.service
sudo systemctl start tradehook-proxy.service

4. Monitoring and Managing the Service: Use systemd commands to manage and monitor your service.

  • Check Statussudo systemctl status tradehook-proxy.service
  • Restart Servicesudo systemctl restart tradehook-proxy.service
  • Stop Servicesudo systemctl stop tradehook-proxy.service