Friends Of AdonisFriends Of Adonis

Drivers

Built-in drivers

File driver

The file driver is the most simple way to configure the maintenance mode and it is the default one.

It works by creating a "lockfile" in your application temporary folder to enable maintenance and delete it to disable it.

config/maintenance.ts
import { ,  } from '@foadonis/maintenance'
 
export default ({
  : 'file',
  : {
    : .(),
  },
})

Cache driver

The cache driver is the perfect choice when running in a distibuted architecture. It relies on the @adonisjs/cache package.

config/maintenance.ts
import { ,  } from '@foadonis/maintenance'
 
export default ({
  : 'cache',
  : {
    : .(),
  },
})

Custom driver

You can create your own driver by extending the MaintenanceDriver class and referencing it in your config/maintenance.ts configuration file.

app/maintenance/drivers.ts
import {  } from '@foadonis/maintenance'
 
export default class  extends  {
  public async (: ): <void> {
    // Store the data somewhere and enable maintenance
  }
 
  public async (): <void> {
    // Disable the maintenance mode
  }
 
  public async (): <boolean> {
    // Returns true if maintenance mode is active
  }
 
  public async (): <> {
    // Returns the maintenance mode data
  }
}
config/maintenance.ts
import {  } from '@foadonis/maintenance'
import  from '#maintenance/drivers/custom_maintenance_driver'
 
export default ({
  : 'custom',
  : {
    : new (),
  },
})

On this page