新增learn-kubernetes(https://github.com/yyong-brs/learn-kubernetes)相关文件
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
ch10-web-ping:
|
||||
image: kiamol/ch10-web-ping:latest-linux-amd64
|
||||
@@ -0,0 +1,5 @@
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
ch10-web-ping:
|
||||
image: kiamol/ch10-web-ping:latest-linux-arm64
|
||||
@@ -0,0 +1,7 @@
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
ch10-web-ping:
|
||||
image: kiamol/ch10-web-ping:latest
|
||||
build:
|
||||
context: ./web-ping
|
||||
@@ -0,0 +1,10 @@
|
||||
$images=$(yq e '.services.[].image' docker-compose.yml)
|
||||
|
||||
foreach ($image in $images)
|
||||
{
|
||||
docker manifest create --amend $image `
|
||||
"$($image)-linux-arm64" `
|
||||
"$($image)-linux-amd64"
|
||||
|
||||
docker manifest push $image
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
FROM node:16.13.1-alpine3.14 AS builder
|
||||
|
||||
WORKDIR /src
|
||||
COPY src/package.json .
|
||||
RUN npm install
|
||||
|
||||
FROM node:16.13.1-alpine3.14
|
||||
|
||||
CMD ["node", "/app/app.js"]
|
||||
|
||||
ENV TARGET="blog.sixeyed.com" \
|
||||
METHOD="HEAD" \
|
||||
INTERVAL="3000"
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=builder /src/node_modules/ /app/node_modules/
|
||||
COPY src/ .
|
||||
@@ -0,0 +1,25 @@
|
||||
const https = require('https');
|
||||
const log = require("./log");
|
||||
|
||||
const options = {
|
||||
hostname: process.env.TARGET,
|
||||
method: process.env.METHOD
|
||||
};
|
||||
|
||||
log.Logger.info('** web-ping ** Pinging: %s; method: %s; %dms intervals', options.hostname, options.method, process.env.INTERVAL);
|
||||
|
||||
let i = 1;
|
||||
let start = new Date().getTime();
|
||||
setInterval(() => {
|
||||
start = new Date().getTime();
|
||||
log.Logger.debug('Making request number: %d; at %d', i++, start);
|
||||
var req = https.request(options, (res) => {
|
||||
var end = new Date().getTime();
|
||||
var duration = end-start;
|
||||
log.Logger.debug('Got response status: %s at %d; duration: %dms', res.statusCode, end, duration);
|
||||
});
|
||||
req.on('error', (e) => {
|
||||
console.error(e);
|
||||
});
|
||||
req.end();
|
||||
}, process.env.INTERVAL)
|
||||
@@ -0,0 +1,16 @@
|
||||
const { format, transports } = require('winston');
|
||||
var logConfig = module.exports = {};
|
||||
|
||||
logConfig.options = {
|
||||
transports: [
|
||||
new transports.Console({
|
||||
level: 'debug',
|
||||
format: format.combine(
|
||||
format.splat(),
|
||||
format.printf(log => {
|
||||
return `${log.message}`
|
||||
})
|
||||
)
|
||||
})
|
||||
]
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
const winston = require('winston');
|
||||
var logConfig = require('./config/logConfig');
|
||||
|
||||
const logger = winston.createLogger(logConfig.options);
|
||||
exports.Logger = logger;
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "web-ping",
|
||||
"version": "1.0.0",
|
||||
"main": "app.js",
|
||||
"author": "kiamol",
|
||||
"dependencies": {
|
||||
"winston": "3.3.3"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user