mirror of
https://github.com/jpetazzo/container.training.git
synced 2026-02-14 17:49:59 +00:00
We want to be able to run on IPv6-only clusters (as well as legacy IPv4 clusters, as well as DualStack clusters). This requires minor changes in the code, because in multiple places, we were binding listening sockets explicitly to 0.0.0.0. We change this to :: instead, and in some cases, we make it easier to change that if needed (e.g. through environment variables).
41 lines
793 B
JavaScript
41 lines
793 B
JavaScript
import express from 'express';
|
|
import morgan from 'morgan';
|
|
import { createClient } from 'redis';
|
|
|
|
var client = await createClient({
|
|
url: "redis://redis",
|
|
socket: {
|
|
family: 0
|
|
}
|
|
})
|
|
.on("error", function (err) {
|
|
console.error("Redis error", err);
|
|
})
|
|
.connect();
|
|
|
|
var app = express();
|
|
|
|
app.use(morgan('common'));
|
|
|
|
app.get('/', function (req, res) {
|
|
res.redirect('/index.html');
|
|
});
|
|
|
|
app.get('/json', async(req, res) => {
|
|
var coins = await client.hLen('wallet');
|
|
var hashes = await client.get('hashes');
|
|
var now = Date.now() / 1000;
|
|
res.json({
|
|
coins: coins,
|
|
hashes: hashes,
|
|
now: now
|
|
});
|
|
});
|
|
|
|
app.use(express.static('files'));
|
|
|
|
var server = app.listen(80, function () {
|
|
console.log('WEBUI running on port 80');
|
|
});
|
|
|