Recommendations for running in production

There are special considerations to take into account when running Stardust in production. This guide will help you understand the best practices for running Stardust in production.

Process manager

It is recommended to use a process manager to run Stardust in production. You can use something like pm2 or just a systemd service. This will ensure that Stardust is always running and will automatically restart if it crashes.

pm2

To use pm2, first install it globally:

pnpm i -g pm2

Then start Stardust with pm2. You can prepend the port env before the command:

pm2 start "pnpm start" --name stardust

systemd

To use systemd, create a service file at /etc/systemd/system/stardust.service:

[Unit]
Description=Stardust SystemD service
# If postgres is running as a service as well as docker
After=docker.service postgresql.service
[Service]
# Where GitHub repository is cloned
WorkingDirectory=/home/ubuntu/stardust
DynamicUser=yes
NoNewPrivileges=yes
# might be different, run `which pnpm`
ExecStart=/usr/bin/pnpm start
# Useful for docker installations
ExecStartPre=docker start stardust-postgres
Restart=on-failure
RestartSec=5
# pnpm install directory might make you set the user to root
User=root
# Use for setting runtime env such as port
Environment="PORT=8090"
[Install]
WantedBy=multi-user.target

After this, add this to the .gitconfig of the user the service is running as:

[safe]
	directory = /home/ubuntu/stardust

Then reload the systemd daemon and start and enable the service:

sudo systemctl daemon-reload
sudo systemctl enable stardust
sudo systemctl start stardust

Last updated on

On this page

Edit on GitHub