Skip to content

Commit

Permalink
Merge pull request #115 from arkedge/make-port-configurable
Browse files Browse the repository at this point in the history
make port configurable
  • Loading branch information
ymgyt authored Nov 19, 2024
2 parents 58eacf0 + a57e577 commit 4d2767c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import {
configLogger();
doLogError();

const defaultPort = 8124;

const logger = log4js.getLogger("general");
logger.info("process started.");

Expand All @@ -36,6 +38,8 @@ const envSchema = z.object({
RULES_FILE_V0: z.string().optional(),
// compatibility with old config format
LABEL_CLASSIFICATION_FILE: z.string().optional(),
// the port that http server listen on
PORT: z.string().optional(),
});

const envParseResult = envSchema.safeParse(process.env);
Expand All @@ -54,6 +58,7 @@ const envInput = {
RULES_FILE_V0:
envParseResult.data.CONFIG_FILE ?? envParseResult.data.RULES_FILE_V0,
LABEL_CLASSIFICATION_FILE: envParseResult.data.LABEL_CLASSIFICATION_FILE,
PORT: envParseResult.data.PORT ?? defaultPort,
};
if (
typeof envInput.RULES_FILE === "undefined" &&
Expand Down Expand Up @@ -211,6 +216,8 @@ app.webhooks.on(
handleEvent(pullRequestEventPayloadToArg),
);

logger.info(`listening on port ${envInput.PORT}`);

const middleware = createNodeMiddleware(app);
http
// eslint-disable-next-line @typescript-eslint/no-misused-promises
Expand All @@ -224,4 +231,4 @@ http
}
res.end();
})
.listen(8124);
.listen(envInput.PORT);

0 comments on commit 4d2767c

Please sign in to comment.