diff --git a/apps/cron/20260201-000000/index.tsx b/apps/cron/20260201-000000/index.tsx index 49dcf7e..42e8e07 100644 --- a/apps/cron/20260201-000000/index.tsx +++ b/apps/cron/20260201-000000/index.tsx @@ -1,6 +1,6 @@ import { Hype } from '@because/hype' 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 { scheduleJob, stopJob } from './lib/scheduler' import { executeJob } from './lib/executor' @@ -691,6 +691,11 @@ watch(APPS_DIR, { recursive: true }, (_event, filename) => { debounceTimer = setTimeout(rediscover, 100) }) +on(['app:activate', 'app:delete'], (event) => { + console.log(`[cron] ${event.type} ${event.app}, rediscovering jobs...`) + rediscover() +}) + init() export default app.defaults diff --git a/src/server/apps.ts b/src/server/apps.ts index 22a10c8..ade3e7d 100644 --- a/src/server/apps.ts +++ b/src/server/apps.ts @@ -206,6 +206,8 @@ export async function renameApp(oldName: string, newName: string): Promise<{ ok: renameTunnelConfig(oldName, newName) update() + emit({ type: 'app:delete', app: oldName }) + emit({ type: 'app:create', app: newName }) // Restart if it was running if (wasRunning) { diff --git a/tsconfig.json b/tsconfig.json index a53767c..d5ad05c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,5 @@ { - "exclude": ["templates"], + "exclude": ["apps", "templates"], "compilerOptions": { // Environment setup & latest features "lib": [