Systemd Production Service Unit for Node.js Application
[Unit]
Description=Node.js Production Application Service
After=network.target postgresql.service
Wants=postgresql.service
[Service]
Type=simple
User=deploy
Group=deploy
WorkingDirectory=/var/www/app
ExecStart=/usr/bin/node server.js
Restart=always
RestartSec=5s
# Environment Variables
Environment=NODE_ENV=production
Environment=PORT=3000
EnvironmentFile=/var/www/app/.env
# Security Hardening & Sandboxing
NoNewPrivileges=true
ProtectSystem=full
ProtectHome=true
PrivateTmp=true
LimitNOFILE=65535
# Logging
StandardOutput=journal
StandardError=journal
SyslogIdentifier=node-app
[Install]
WantedBy=multi-user.target