forked from torrust/torrust-index-gui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: [torrust#263] add healthcheck for Index GUI container
- Loading branch information
1 parent
dfe48e1
commit 1208346
Showing
6 changed files
with
50 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/share/container/health_check.js |
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,40 @@ | ||
/* | ||
This application is used to create a `HEALTHCHECK` instruction in the | ||
`Dockerfile` or `Containerfile`. | ||
Usage: | ||
node health_check.js 3000 | ||
node health_check.js PORT | ||
*/ | ||
|
||
const http = require("http"); | ||
|
||
// Retrieve the port number from the command-line arguments. | ||
// Default to 3000 if no argument is provided | ||
const port = process.argv[2] || "3000"; | ||
|
||
const options = { | ||
host: "localhost", | ||
port, | ||
timeout: 2000 | ||
}; | ||
|
||
const request = http.request(options, (res) => { | ||
console.log(`STATUS: ${res.statusCode}`); | ||
if (res.statusCode === 200) { | ||
process.exit(0); | ||
} | ||
else { | ||
process.exit(1); | ||
} | ||
}); | ||
|
||
request.on("error", function (err) { | ||
console.log("ERROR"); | ||
process.exit(1); | ||
}); | ||
|
||
request.end(); |