File tree Expand file tree Collapse file tree 3 files changed +17
-14
lines changed Expand file tree Collapse file tree 3 files changed +17
-14
lines changed Original file line number Diff line number Diff line change 1
1
import process from 'node:process'
2
- import { generateMigrations } from '@stacksjs/database'
2
+ import { generateMigrations , runDatabaseMigration } from '@stacksjs/database'
3
3
import { log } from '@stacksjs/logging'
4
4
5
5
// this is run and checks whether new created or update migrations need to be generated
@@ -11,12 +11,12 @@ if (result?.isErr()) {
11
11
process . exit ( 1 )
12
12
}
13
13
14
- // const result2 = await runDatabaseMigration()
14
+ const result2 = await runDatabaseMigration ( )
15
15
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
+ }
21
21
22
22
process . exit ( 0 )
Original file line number Diff line number Diff line change @@ -4,9 +4,9 @@ import { runScheduler } from '@stacksjs/scheduler'
4
4
5
5
const result = await runScheduler ( )
6
6
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
+ }
11
11
12
- // process.exit(0)
12
+ process . exit ( 0 )
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { path } from '@stacksjs/path'
3
3
import type { JobOptions } from '@stacksjs/types'
4
4
import { Every } from '@stacksjs/types'
5
5
import { snakeCase } from '@stacksjs/strings'
6
+ import { err , ok , type Err , type Ok } from '@stacksjs/error-handling'
6
7
7
8
interface JobSchedule {
8
9
jobName : string
@@ -13,7 +14,7 @@ interface JobSchedule {
13
14
14
15
const scheduleFile = path . storagePath ( 'framework/core/scheduler/src/schedules/jobSchedule.json' )
15
16
16
- export async function runScheduler ( ) : Promise < void > {
17
+ export async function runScheduler ( ) : Promise < Ok < string , never > | Err < string , any > > {
17
18
const now = new Date ( )
18
19
let schedules = loadSchedule ( )
19
20
@@ -43,7 +44,7 @@ export async function runScheduler(): Promise<void> {
43
44
}
44
45
}
45
46
} catch ( error ) {
46
- console . error ( `Failed to process job file : ${ jobFile } `, error )
47
+ return err ( `Scheduler failed execute job: ${ jobFile } `)
47
48
}
48
49
}
49
50
@@ -65,6 +66,8 @@ export async function runScheduler(): Promise<void> {
65
66
66
67
// Save updated schedules
67
68
saveSchedule ( schedules )
69
+
70
+ return ok ( 'Schedules ran successfully' )
68
71
}
69
72
70
73
function isDueToRun ( nextRunTime : Date , currentDate : Date ) : boolean {
You can’t perform that action at this time.
0 commit comments