mirror of
https://github.com/barkeser2002/mcsleepingserverstarter.git
synced 2026-09-25 12:16:00 +03:00
26 lines
557 B
TypeScript
26 lines
557 B
TypeScript
import { createConnection } from 'net';
|
|
|
|
export const isInDev = () => {
|
|
if (process.env.NODE_ENV === 'development') {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
export const isPortTaken = (port: number) => new Promise<boolean>((resolve, reject) => {
|
|
|
|
const client = createConnection({ port }, () => {
|
|
client.end();
|
|
resolve(true);
|
|
}).once("error", () => {
|
|
resolve(false);
|
|
});
|
|
|
|
});
|
|
|
|
export enum ServerStatus {
|
|
Sleeping = 'Sleeping',
|
|
Running = 'Running',
|
|
Starting = 'Starting',
|
|
Stopped = 'Stopped'
|
|
} |