File tree Expand file tree Collapse file tree 2 files changed +20
-8
lines changed Expand file tree Collapse file tree 2 files changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -2,10 +2,19 @@ import RoleService from 'controllers/Role/service'
22import cron from 'node-cron'
33import ConstRoles from 'constants/ConstRoles'
44
5- // Run this job every 30 minutes
6- const GetRoleTask = cron . schedule ( '30 * * * *' , async ( ) => {
7- const data = await RoleService . getOne ( ConstRoles . ID_UMUM )
8- console . log ( 'Running task check get role by id' , { data } )
9- } )
5+ class RoleJob {
6+ /**
7+ * Get Role Task
8+ */
9+ public static getRole ( ) {
10+ // Run this job every 30 minutes
11+ const task = cron . schedule ( '30 * * * *' , async ( ) => {
12+ const data = await RoleService . getOne ( ConstRoles . ID_UMUM )
13+ console . log ( 'Running task check get role by id' , { data } )
14+ } )
1015
11- export { GetRoleTask }
16+ return task
17+ }
18+ }
19+
20+ export default RoleJob
Original file line number Diff line number Diff line change 1- import { GetRoleTask } from 'jobs/RoleJob'
1+ import RoleJob from 'jobs/RoleJob'
22
33function initialJobs ( ) {
44 // Role Jobs
5- GetRoleTask . start ( )
5+ const getRoleTask = RoleJob . getRole ( )
6+ getRoleTask . start ( )
7+
8+ // Other Jobs
69}
710
811export default initialJobs
You can’t perform that action at this time.
0 commit comments