You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.1 KiB

import {AppClass} from './AppClass'
* The various statuses of a Unit.
export enum UnitStatus {
* 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> | 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> | void {} // eslint-disable-line @typescript-eslint/no-empty-function