Kaynağa Gözat

fix: build should work even when redis is down

version-14
Faris Ansari 4 yıl önce
ebeveyn
işleme
e711ada61c
2 değiştirilmiş dosya ile 22 ekleme ve 5 silme
  1. +12
    -4
      esbuild/esbuild.js
  2. +10
    -1
      node_utils.js

+ 12
- 4
esbuild/esbuild.js Dosyayı Görüntüle

@@ -103,6 +103,7 @@ async function execute() {
log_error("There were some problems during build");
log();
log(chalk.dim(e.stack));
return;
}

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
return new Promise(resolve => {
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 => {
if (err) {
log_warn("Could not update assets_json in redis_cache");
}
client.unref();
resolve();
});
@@ -407,8 +409,11 @@ function run_build_command_for_apps(apps) {
}

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
let subscriber = get_redis_subscriber("redis_socketio");
subscriber.on("error", _ => {
log_warn("Cannot connect to redis_socketio for browser events");
});

let payload = null;
if (error) {
@@ -440,6 +445,9 @@ async function notify_redis({ error, success }) {

function open_in_editor() {
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) => {
if (event === "open_in_editor") {
file = JSON.parse(file);


+ 10
- 1
node_utils.js Dosyayı Görüntüle

@@ -41,7 +41,16 @@ function get_conf() {
function get_redis_subscriber(kind="redis_socketio") {
const conf = get_conf();
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 = {


Yükleniyor…
İptal
Kaydet