-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'AI-250-debug-open-files' into 'master'
Add logging for AI-250 "Debug open files" See merge request developers/ask-izzy!640
- Loading branch information
Showing
7 changed files
with
67 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* @flow */ | ||
import { lsof } from "list-open-files" | ||
export default async function handler(req: any, res: any): Promise<void> { | ||
// Obviously not super secure but we're only trying to make this | ||
// slightly more secuire than an unlisted url | ||
const { auth } = req.query | ||
if (!process.env.STATIC_PAGE_REGENERATION_SECRET || (auth !== process.env.STATIC_PAGE_REGENERATION_SECRET)) { | ||
return res.status(404).send("404") | ||
} | ||
|
||
try { | ||
const processInfos = await lsof() | ||
|
||
const files = processInfos[0]?.files | ||
if (!files) { | ||
return res.status(500).send("no files") | ||
} | ||
const sockets = files.filter(file => (file.type === "IP") && file.from) | ||
const nonSockets = files.filter(file => (file.type !== "IP") || !file.from) | ||
const incomingSockets = sockets.filter(socket => socket.from.port === 8000) | ||
const outgoingSockets = sockets.filter(socket => socket.from.port !== 8000) | ||
return res.status(200).send({ | ||
incomingSockets, | ||
outgoingSockets, | ||
nonSockets, | ||
}) | ||
} catch (error) { | ||
return res.status(500).send("error: " + error) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters