fix(migration): update systemd service file during v3→v4 migration
Critical fixes for v3→v4 migration: 1. install.sh: Auto-update systemd service file during migration - Calls 'nupst service enable' before restarting service - Only when migrating from v3 (OLD_NODE_INSTALL=1) - Ensures service file has correct v4 paths 2. ts/systemd.ts: Fix hardcoded v3 paths in service template - ExecStart: /opt/nupst/bin/nupst daemon-start (v3, broken) → /usr/local/bin/nupst service start-daemon (v4, correct) - Description: Updated to 'Deno-powered UPS Monitoring Tool' - Added RestartSec=10 (prevent rapid restart loops) - Removed NODE_ENV=production (not needed for Deno) - WorkingDirectory: /tmp → /opt/nupst Without these fixes: - Service fails to start after migration - Service file points to non-existent /opt/nupst/bin/nupst - Users must manually run 'nupst service enable' Discovered via Docker migration testing in test/manualdocker/
This commit is contained in:
@@ -340,6 +340,14 @@ fi
|
|||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
# Update systemd service file if migrating from v3
|
||||||
|
if [ $SERVICE_WAS_RUNNING -eq 1 ] && [ $OLD_NODE_INSTALL -eq 1 ]; then
|
||||||
|
echo "Updating systemd service file for v4..."
|
||||||
|
$BINARY_PATH service enable > /dev/null 2>&1
|
||||||
|
echo "Service file updated."
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
|
||||||
# Restart service if it was running before update
|
# Restart service if it was running before update
|
||||||
if [ $SERVICE_WAS_RUNNING -eq 1 ]; then
|
if [ $SERVICE_WAS_RUNNING -eq 1 ]; then
|
||||||
echo "Restarting NUPST service..."
|
echo "Restarting NUPST service..."
|
||||||
|
@@ -15,17 +15,17 @@ export class NupstSystemd {
|
|||||||
|
|
||||||
/** Template for the systemd service file */
|
/** Template for the systemd service file */
|
||||||
private readonly serviceTemplate = `[Unit]
|
private readonly serviceTemplate = `[Unit]
|
||||||
Description=Node.js UPS Shutdown Tool for Multiple UPS Devices
|
Description=NUPST - Deno-powered UPS Monitoring Tool
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=/opt/nupst/bin/nupst daemon-start
|
ExecStart=/usr/local/bin/nupst service start-daemon
|
||||||
Restart=always
|
Restart=always
|
||||||
|
RestartSec=10
|
||||||
User=root
|
User=root
|
||||||
Group=root
|
Group=root
|
||||||
Environment=PATH=/usr/bin:/usr/local/bin
|
Environment=PATH=/usr/bin:/usr/local/bin
|
||||||
Environment=NODE_ENV=production
|
WorkingDirectory=/opt/nupst
|
||||||
WorkingDirectory=/tmp
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
Reference in New Issue
Block a user