Add persistent HTTP server to background service daemon
This commit is contained in:
1 parent
13ed555bbb
commit
f183cc8294
7 files changed
+237
-50
No files matched your search
+5
-2
@@ -8,9 +8,12 @@ export type HttpServerOptions = {
|
||||
silent?: boolean;
|
||||
};
|
||||
|
||||
export const DEFAULT_HTTP_PORT = 8787;
|
||||
export const DEFAULT_HTTP_HOST = "127.0.0.1";
|
||||
|
||||
export async function startHttpServer(options: HttpServerOptions = {}): Promise<Server> {
|
||||
const port = options.port ?? (process.env.PORT ? Number.parseInt(process.env.PORT, 10) : 8787);
|
||||
const host = options.host ?? (process.env.HOST ? process.env.HOST : "127.0.0.1");
|
||||
const port = options.port ?? (process.env.PORT ? Number.parseInt(process.env.PORT, 10) : DEFAULT_HTTP_PORT);
|
||||
const host = options.host ?? (process.env.HOST ? process.env.HOST : DEFAULT_HTTP_HOST);
|
||||
|
||||
const server = createServer(async (req, res) => {
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user