mirror of
https://github.com/jpetazzo/container.training.git
synced 2026-07-21 22:07:13 +00:00
add resilience
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
var express = require('express');
|
||||
var app = express();
|
||||
var redis = require('redis');
|
||||
|
||||
app.get('/', function (req, res) {
|
||||
res.redirect('/index.html');
|
||||
});
|
||||
|
||||
app.get('/json', function (req, res) {
|
||||
redis.hlen('wallet', function (err, coins) {
|
||||
redis.get('hashes', function (err, hashes) {
|
||||
var client = redis.createClient(6379, 'redis');
|
||||
client.hlen('wallet', function (err, coins) {
|
||||
client.get('hashes', function (err, hashes) {
|
||||
var now = Date.now() / 1000;
|
||||
res.json( {
|
||||
coins: coins,
|
||||
@@ -20,8 +22,6 @@ app.get('/json', function (req, res) {
|
||||
|
||||
app.use(express.static('files'));
|
||||
|
||||
var redis = require('redis').createClient(6379, 'redis');
|
||||
|
||||
var server = app.listen(80, function () {
|
||||
console.log('WEBUI running on port 80');
|
||||
});
|
||||
|
||||
@@ -59,5 +59,11 @@ def work_once():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
work_loop()
|
||||
try:
|
||||
work_loop()
|
||||
except:
|
||||
log.exception()
|
||||
log.error("Waiting 10s and restarting.")
|
||||
time.sleep(10)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user