import {AppClass} from './AppClass' /** * The various statuses of a Unit. */ export enum UnitStatus { Starting, Started, Stopping, Stopped, Error, } /** * Base class for a service that can be registered with the application * that is started and stopped during the application lifecycle. */ export abstract class Unit extends AppClass { /** The current status of the unit. */ public status: UnitStatus = UnitStatus.Stopped /** * This method is called to start the unit when the application is booting. * Here, you should do any setup required to get the package up and running. */ public up(): Promise | void {} // eslint-disable-line @typescript-eslint/no-empty-function /** * This method is called to stop the unit when the application is shutting down. * Here, you should do any teardown required to stop the package cleanly. * * IN PARTICULAR take care to free blocking resources that could prevent the * process from exiting without a kill. */ public down(): Promise | void {} // eslint-disable-line @typescript-eslint/no-empty-function }