Added support for hot reload, start, stop, restart, and virtual hosts

This commit is contained in:
Gregory Magarshak
2026-07-21 18:12:11 -04:00
parent 62d9b23396
commit bdac23b6f2
9 changed files with 469 additions and 10 deletions
+52
View File
@@ -0,0 +1,52 @@
# Running Qbix Server as a Service
## Linux (systemd)
```bash
# Edit paths in the service file
sudo cp service/qbixserver.service /etc/systemd/system/
sudo systemctl daemon-reload
# Start, stop, reload
sudo systemctl start qbixserver
sudo systemctl stop qbixserver
sudo systemctl reload qbixserver # re-reads config, restarts workers
# Auto-start on boot
sudo systemctl enable qbixserver
# View logs
journalctl -u qbixserver -f
```
## macOS (launchd)
```bash
# Edit paths in the plist file
cp service/com.qbix.server.plist ~/Library/LaunchAgents/
# Start, stop
launchctl load ~/Library/LaunchAgents/com.qbix.server.plist
launchctl unload ~/Library/LaunchAgents/com.qbix.server.plist
# View logs
tail -f /var/log/qbixserver.log
```
For system-wide (not per-user), use `/Library/LaunchDaemons/` instead.
## Manual (any platform)
```bash
# Start in background
./qbixserver.php --root=./web --port=8080 --pid=./qbixserver.pid &
# Stop
./qbixserver.php --stop --pid=./qbixserver.pid
# Reload (graceful restart)
./qbixserver.php --reload --pid=./qbixserver.pid
# Test config
./qbixserver.php -t
```
+32
View File
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.qbix.server</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/php</string>
<string>/var/www/myapp/qbixserver.php</string>
<string>--root=./web</string>
<string>--port=8080</string>
<string>--pid=/tmp/qbixserver.pid</string>
</array>
<key>WorkingDirectory</key>
<string>/var/www/myapp</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>/var/log/qbixserver.log</string>
<key>StandardErrorPath</key>
<string>/var/log/qbixserver.error.log</string>
</dict>
</plist>
+25
View File
@@ -0,0 +1,25 @@
[Unit]
Description=Qbix Server
After=network.target
[Service]
Type=simple
User=www-data
Group=www-data
WorkingDirectory=/var/www/myapp
ExecStart=/usr/bin/php /var/www/myapp/qbixserver.php --root=./web --port=8080 --pid=/var/run/qbixserver.pid
ExecStop=/usr/bin/php /var/www/myapp/qbixserver.php --stop --pid=/var/run/qbixserver.pid
ExecReload=/usr/bin/php /var/www/myapp/qbixserver.php --reload --pid=/var/run/qbixserver.pid
PIDFile=/var/run/qbixserver.pid
Restart=on-failure
RestartSec=5
StandardOutput=journal
StandardError=journal
# Security hardening
NoNewPrivileges=true
ProtectSystem=strict
ReadWritePaths=/var/www/myapp /var/run
[Install]
WantedBy=multi-user.target