fix: build should work even when redis is down
This commit is contained in:
parent
f8ca990a83
commit
e711ada61c
2 changed files with 22 additions and 5 deletions
|
|
@ -103,6 +103,7 @@ async function execute() {
|
||||||
log_error("There were some problems during build");
|
log_error("There were some problems during build");
|
||||||
log();
|
log();
|
||||||
log(chalk.dim(e.stack));
|
log(chalk.dim(e.stack));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!WATCH_MODE) {
|
if (!WATCH_MODE) {
|
||||||
|
|
@ -374,10 +375,11 @@ function update_assets_json_in_cache(assets_json) {
|
||||||
// update assets_json cache in redis, so that it can be read directly by python
|
// update assets_json cache in redis, so that it can be read directly by python
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
let client = get_redis_subscriber("redis_cache");
|
let client = get_redis_subscriber("redis_cache");
|
||||||
|
// handle error event to avoid printing stack traces
|
||||||
|
client.on("error", _ => {
|
||||||
|
log_warn("Cannot connect to redis_cache to update assets_json");
|
||||||
|
});
|
||||||
client.set("assets_json", JSON.stringify(assets_json), err => {
|
client.set("assets_json", JSON.stringify(assets_json), err => {
|
||||||
if (err) {
|
|
||||||
log_warn("Could not update assets_json in redis_cache");
|
|
||||||
}
|
|
||||||
client.unref();
|
client.unref();
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
|
|
@ -407,8 +409,11 @@ function run_build_command_for_apps(apps) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function notify_redis({ error, success }) {
|
async function notify_redis({ error, success }) {
|
||||||
let subscriber = get_redis_subscriber("redis_socketio");
|
|
||||||
// notify redis which in turns tells socketio to publish this to browser
|
// notify redis which in turns tells socketio to publish this to browser
|
||||||
|
let subscriber = get_redis_subscriber("redis_socketio");
|
||||||
|
subscriber.on("error", _ => {
|
||||||
|
log_warn("Cannot connect to redis_socketio for browser events");
|
||||||
|
});
|
||||||
|
|
||||||
let payload = null;
|
let payload = null;
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|
@ -440,6 +445,9 @@ async function notify_redis({ error, success }) {
|
||||||
|
|
||||||
function open_in_editor() {
|
function open_in_editor() {
|
||||||
let subscriber = get_redis_subscriber("redis_socketio");
|
let subscriber = get_redis_subscriber("redis_socketio");
|
||||||
|
subscriber.on("error", _ => {
|
||||||
|
log_warn("Cannot connect to redis_socketio for open_in_editor events");
|
||||||
|
});
|
||||||
subscriber.on("message", (event, file) => {
|
subscriber.on("message", (event, file) => {
|
||||||
if (event === "open_in_editor") {
|
if (event === "open_in_editor") {
|
||||||
file = JSON.parse(file);
|
file = JSON.parse(file);
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,16 @@ function get_conf() {
|
||||||
function get_redis_subscriber(kind="redis_socketio") {
|
function get_redis_subscriber(kind="redis_socketio") {
|
||||||
const conf = get_conf();
|
const conf = get_conf();
|
||||||
const host = conf[kind] || conf.redis_async_broker_port;
|
const host = conf[kind] || conf.redis_async_broker_port;
|
||||||
return redis.createClient(host);
|
return redis.createClient({
|
||||||
|
host,
|
||||||
|
retry_strategy: function(options) {
|
||||||
|
// abort after 5 connection attempts
|
||||||
|
if (options.attempt > 5) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return Math.min(options.attempt * 100, 2000);
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue