mirror of
https://github.com/Qbix/webserver.git
synced 2026-07-22 07:57:23 +02:00
Added support for hot reload, start, stop, restart, and virtual hosts
This commit is contained in:
@@ -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
|
||||
```
|
||||
@@ -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>
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user