[cron] reload jobs on renames/deploys

This commit is contained in:
Chris Wanstrath 2026-02-15 08:44:48 -08:00
parent 565f4924e8
commit 1015e20cf9
3 changed files with 9 additions and 2 deletions

View File

@ -1,6 +1,6 @@
import { Hype } from '@because/hype' import { Hype } from '@because/hype'
import { define, stylesToCSS } from '@because/forge' import { define, stylesToCSS } from '@because/forge'
import { baseStyles, ToolScript, theme } from '@because/toes/tools' import { baseStyles, on, ToolScript, theme } from '@because/toes/tools'
import { discoverCronJobs } from './lib/discovery' import { discoverCronJobs } from './lib/discovery'
import { scheduleJob, stopJob } from './lib/scheduler' import { scheduleJob, stopJob } from './lib/scheduler'
import { executeJob } from './lib/executor' import { executeJob } from './lib/executor'
@ -691,6 +691,11 @@ watch(APPS_DIR, { recursive: true }, (_event, filename) => {
debounceTimer = setTimeout(rediscover, 100) debounceTimer = setTimeout(rediscover, 100)
}) })
on(['app:activate', 'app:delete'], (event) => {
console.log(`[cron] ${event.type} ${event.app}, rediscovering jobs...`)
rediscover()
})
init() init()
export default app.defaults export default app.defaults

View File

@ -206,6 +206,8 @@ export async function renameApp(oldName: string, newName: string): Promise<{ ok:
renameTunnelConfig(oldName, newName) renameTunnelConfig(oldName, newName)
update() update()
emit({ type: 'app:delete', app: oldName })
emit({ type: 'app:create', app: newName })
// Restart if it was running // Restart if it was running
if (wasRunning) { if (wasRunning) {

View File

@ -1,5 +1,5 @@
{ {
"exclude": ["templates"], "exclude": ["apps", "templates"],
"compilerOptions": { "compilerOptions": {
// Environment setup & latest features // Environment setup & latest features
"lib": [ "lib": [