fix(web): webhook never reloads itself during deploy (was interrupting backend reload)
This commit is contained in:
+16
-8
@@ -45,6 +45,9 @@ const RESTART_TARGETS = (process.env.PM2_RESTART_TARGETS || 'tssbot-web,tssbot-b
|
|||||||
.map((target) => target.trim())
|
.map((target) => target.trim())
|
||||||
.filter((target) => /^[A-Za-z0-9_.:-]{1,80}$/.test(target))
|
.filter((target) => /^[A-Za-z0-9_.:-]{1,80}$/.test(target))
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
|
|
||||||
|
// This webhook's own PM2 process name — never reload it during its own deploy.
|
||||||
|
const SELF_PM2_NAME = process.env.WEBHOOK_PM2_NAME || 'tssbot-webhook'
|
||||||
const DIST_DIR = path.join(__dirname, 'dist')
|
const DIST_DIR = path.join(__dirname, 'dist')
|
||||||
const NEXT_DIST_DIR = path.join(__dirname, 'dist-next')
|
const NEXT_DIST_DIR = path.join(__dirname, 'dist-next')
|
||||||
const PREVIOUS_DIST_DIR = path.join(__dirname, 'dist-previous')
|
const PREVIOUS_DIST_DIR = path.join(__dirname, 'dist-previous')
|
||||||
@@ -563,14 +566,19 @@ async function deploy(push) {
|
|||||||
// Reload via the ecosystem file (not by bare name) with --only so each deploy
|
// Reload via the ecosystem file (not by bare name) with --only so each deploy
|
||||||
// re-reads the committed env blocks (e.g. VEHICLE_* paths). `pm2 reload <name>
|
// re-reads the committed env blocks (e.g. VEHICLE_* paths). `pm2 reload <name>
|
||||||
// --update-env` would only merge the CLI's process.env and ignore the file.
|
// --update-env` would only merge the CLI's process.env and ignore the file.
|
||||||
// --only excludes tssbot-webhook so the webhook never reloads itself mid-deploy.
|
// Exclude this webhook process itself: reloading it here kills the process
|
||||||
await run('pm2', [
|
// running this deploy mid-command, interrupting the remaining reloads. The
|
||||||
'reload',
|
// webhook is reloaded separately when its own code changes.
|
||||||
'ecosystem.config.cjs',
|
const reloadTargets = RESTART_TARGETS.filter((t) => t !== SELF_PM2_NAME)
|
||||||
'--only',
|
if (reloadTargets.length) {
|
||||||
RESTART_TARGETS.join(','),
|
await run('pm2', [
|
||||||
'--update-env',
|
'reload',
|
||||||
])
|
'ecosystem.config.cjs',
|
||||||
|
'--only',
|
||||||
|
reloadTargets.join(','),
|
||||||
|
'--update-env',
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
await notifyDeployCompleted(push, diff)
|
await notifyDeployCompleted(push, diff)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user