import {Unit} from '../lifecycle/Unit' import {Inject} from '../di' import {Logging} from './Logging' import * as process from 'process' export class Foreground extends Unit { @Inject() protected readonly logging!: Logging protected resolver?: () => unknown public up(): Promise { return new Promise(res => { this.resolver = res this.logging.success(`Application started! Press ^C or send SIGINT to stop.`) process.stdin.resume() process.on('SIGINT', res) }) } public down(): void { this.resolver?.() } }