# CBM Portal Backend - Systemd Service Configuration # Copy this file to: /etc/systemd/system/cbm-portal.service [Unit] Description=CBM Portal Backend Service Documentation=https://github.com/your-org/cbm-portal-backend After=syslog.target network.target postgresql.service Wants=postgresql.service [Service] Type=simple User=cbmportal Group=cbmportal WorkingDirectory=/home/cbmportal/app # Application startup ExecStart=/usr/bin/java -jar /home/cbmportal/app/cbm-portal.jar --spring.profiles.active=stage # Process management SuccessExitStatus=143 Restart=always RestartSec=10 TimeoutStartSec=90 TimeoutStopSec=30 # Logging StandardOutput=append:/home/cbmportal/logs/cbm-portal.log StandardError=append:/home/cbmportal/logs/cbm-portal-error.log SyslogIdentifier=cbm-portal # Performance tuning (adjust based on your needs) # Environment="JAVA_OPTS=-Xmx2g -Xms512m -XX:+UseG1GC" # Security hardening NoNewPrivileges=true PrivateTmp=true ProtectSystem=strict ProtectHome=true ReadWritePaths=/home/cbmportal/public_html/portal/forms ReadWritePaths=/home/cbmportal/logs # Resource limits LimitNOFILE=65535 LimitNPROC=4096 [Install] WantedBy=multi-user.target Alias=cbm-portal.service # Installation Instructions: # 1. Copy this file: # sudo cp cbm-portal.service /etc/systemd/system/ # # 2. Set up environment variables (see environment.conf.example) # # 3. Reload systemd: # sudo systemctl daemon-reload # # 4. Enable service to start on boot: # sudo systemctl enable cbm-portal # # 5. Start the service: # sudo systemctl start cbm-portal # # 6. Check status: # sudo systemctl status cbm-portal # # 7. View logs: # journalctl -u cbm-portal -f