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.
25 lines
621 B
25 lines
621 B
2 years ago
|
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<void> {
|
||
|
return new Promise<void>(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?.()
|
||
|
}
|
||
|
}
|