Skip to content

Commit 763be73

Browse files
chore: wip
1 parent b15bf94 commit 763be73

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import process from 'node:process'
2-
import { generateMigrations } from '@stacksjs/database'
2+
import { generateMigrations, runDatabaseMigration } from '@stacksjs/database'
33
import { log } from '@stacksjs/logging'
44

55
// this is run and checks whether new created or update migrations need to be generated
@@ -11,12 +11,12 @@ if (result?.isErr()) {
1111
process.exit(1)
1212
}
1313

14-
// const result2 = await runDatabaseMigration()
14+
const result2 = await runDatabaseMigration()
1515

16-
// if (result2.isErr()) {
17-
// log.error('runDatabaseMigration failed')
18-
// log.error(result2.error)
19-
// process.exit(1)
20-
// }
16+
if (result2.isErr()) {
17+
log.error('runDatabaseMigration failed')
18+
log.error(result2.error)
19+
process.exit(1)
20+
}
2121

2222
process.exit(0)

storage/framework/core/actions/src/schedule/run.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { runScheduler } from '@stacksjs/scheduler'
44

55
const result = await runScheduler()
66

7-
// if (result?.isErr()) {
8-
// console.error(result.error)
9-
// log.error('Schedule run failed', result.error)
10-
// }
7+
if (result?.isErr()) {
8+
console.error(result.error)
9+
log.error('Schedule run failed', result.error)
10+
}
1111

12-
// process.exit(0)
12+
process.exit(0)

storage/framework/core/scheduler/src/run.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { path } from '@stacksjs/path'
33
import type { JobOptions } from '@stacksjs/types'
44
import { Every } from '@stacksjs/types'
55
import { snakeCase } from '@stacksjs/strings'
6+
import { err, ok, type Err, type Ok } from '@stacksjs/error-handling'
67

78
interface JobSchedule {
89
jobName: string
@@ -13,7 +14,7 @@ interface JobSchedule {
1314

1415
const scheduleFile = path.storagePath('framework/core/scheduler/src/schedules/jobSchedule.json')
1516

16-
export async function runScheduler(): Promise<void> {
17+
export async function runScheduler(): Promise<Ok<string, never> | Err<string, any>> {
1718
const now = new Date()
1819
let schedules = loadSchedule()
1920

@@ -43,7 +44,7 @@ export async function runScheduler(): Promise<void> {
4344
}
4445
}
4546
} catch (error) {
46-
console.error(`Failed to process job file: ${jobFile}`, error)
47+
return err(`Scheduler failed execute job: ${jobFile}`)
4748
}
4849
}
4950

@@ -65,6 +66,8 @@ export async function runScheduler(): Promise<void> {
6566

6667
// Save updated schedules
6768
saveSchedule(schedules)
69+
70+
return ok('Schedules ran successfully')
6871
}
6972

7073
function isDueToRun(nextRunTime: Date, currentDate: Date): boolean {

0 commit comments

Comments
 (0)