Skip to content

Commit

Permalink
Fix pid
Browse files Browse the repository at this point in the history
  • Loading branch information
timonson committed Oct 13, 2023
1 parent 7e99312 commit b462060
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type ServerHandlerOptions<S> = {
state?: S;
enableXResponseTimeHeader?: boolean;
enableLogger?: boolean;
writePid?: boolean;
pid?: { path: string; name?: string; append?: boolean };
};

function setXResponseTimeHeader<C extends Context>(ctx: C) {
Expand Down Expand Up @@ -47,14 +47,14 @@ export function createHandler<C extends Context, S>(
state,
enableXResponseTimeHeader = true,
enableLogger = false,
writePid = true,
pid,
}: ServerHandlerOptions<S> = {},
) {
if (writePid) {
Deno.writeTextFileSync(
new URL("./.pid", Deno.mainModule).pathname,
Deno.pid.toString(),
);
if (pid?.path) {
const pidString = pid.name
? `${pid.name}: ${Deno.pid.toString()}`
: `${Deno.pid.toString()}`;
Deno.writeTextFileSync(pid.path, pidString + "\n", { append: pid.append });
}
return (...tryMiddlewares: Middleware<C>[]) =>
(...catchMiddlewares: Middleware<C>[]) =>
Expand Down

0 comments on commit b462060

Please sign in to comment.