рдЕрд░реЗ,
рдореБрдЭреЗ рдЗрд╕ рдореЙрдбреНрдпреВрд▓ рдХреЛ рдкреБрдирдГ рдЬреЛрдбрд╝рдиреЗ рдХреЗ рд▓рд┐рдП рдирд╣реАрдВ рдорд┐рд▓ рд╕рдХрддрд╛ рд╣реИред
рдпрд╣ рд╡рд┐рдиреНрдпрд╛рд╕ рд▓реЗрдирд╛:
const client = redis.createClient({
no_ready_check: false,
enable_offline_queue: true,
retry_unfulfilled_commands: true,
socket_keepalive: true,
retry_strategy: function (options) {
if (options.error && options.error.code === 'ECONNREFUSED') {
// End reconnecting on a specific error and flush all commands with
// a individual error
return new Error('The server refused the connection');
}
if (options.total_retry_time > 1000 * 60 * 60) {
// End reconnecting after a specific timeout and flush all commands
// with a individual error
return new Error('Retry time exhausted');
}
if (options.attempt > 10) {
// End reconnecting with built in error
return undefined;
}
console.log('here');
// reconnect after
return 100;
},
host: process.env.REDIS_HOST || '127.0.0.1',
port: 6379
});
рдореИрдВ here
рджреЗрдЦрддрд╛ рд╣реВрдВ рдЬрдм рдореИрдВ рдЕрдкрдиреЗ рд╕реНрдерд╛рдиреАрдп рд░реЗрдбрд┐рд╕ рдХреЛ рд░реЛрдХ рджреЗрддрд╛ рд╣реВрдВ, рд▓реЗрдХрд┐рди рдлрд┐рд░ рдореИрдВ рдЗрд╕реЗ рдлрд┐рд░ рд╕реЗ рд╢реБрд░реВ рдХрд░рддрд╛ рд╣реВрдВ рдФрд░ рдХрд┐рд╕реА рднреА рд╕рдордп рдХреА рдкреНрд░рддреАрдХреНрд╖рд╛ рдХрд░рддрд╛ рд╣реВрдВ, рдмрд╛рдж рдХреА рдХреЛрдИ рднреА рдХреЙрд▓ рдореБрдЭреЗ рджреЗрддреА рд╣реИ:
{ AbortError: EXEC can't be processed. The connection is already closed.
at handle_offline_command (/Users/kstoney/git/autotrader/platform-alert-forwarder/node_modules/redis/index.js:851:15)
at RedisClient.internal_send_command (/Users/kstoney/git/autotrader/platform-alert-forwarder/node_modules/redis/index.js:885:9)
at Multi.exec_transaction (/Users/kstoney/git/autotrader/platform-alert-forwarder/node_modules/redis/lib/multi.js:115:18)
at Object.RedisCache.self.set (/Users/kstoney/git/autotrader/platform-alert-forwarder/lib/caches/redis.js:41:8)
at Object.sendMessage [as handle] (/Users/kstoney/git/autotrader/platform-alert-forwarder/lib/forwarders/slack.js:197:28)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
command: 'EXEC',
code: 'NR_CLOSED',
errors:
[ { AbortError: SET can't be processed. The connection is already closed.
рдХреЛрдИ рд╡рд┐рдЪрд╛рд░? рдореБрдЭреЗ рдмреНрд▓рд┐рд╕ рдХреЛ рд▓рд╛рд▓ рдХрд░рдиреЗ рдХреЗ рд▓рд┐рдП рдХреБрдЫ рд╕рд╣рд┐рд╖реНрдгреБрддрд╛ рдХреА рдЖрд╡рд╢реНрдпрдХрддрд╛ рд╣реИред
рдХреБрдЫ рд╕рдорд╕реНрдпрд╛рдУрдВ рдХреЗ рдмрд┐рдирд╛ рд╕рдорд╛рди рд╕рдорд╕реНрдпрд╛ рдЬреИрд╕реЗ рдХрддрд╛рд░ рдСрдлрд╝рд▓рд╛рдЗрди, рдореЗрд░рд╛ рдХреЙрдиреНрдлрд╝рд┐рдЧрд░реЗрд╢рди рдпрд╣ рдиреАрдЪреЗ рд╣реИ:
var client = redis.createClient({
port: process.env.REDIS_PORT,
host: process.env.REDIS_HOST,
retry_strategy: function (options) {
if (options.error && options.error.code === 'ECONNREFUSED') {
// End reconnecting on a specific error and flush all commands with
// a individual error
logger.debug('[Redis Strategy] - Connection Refused options:', options);
return new Error('The server refused the connection');
}
if (options.total_retry_time > 1000 * 60 * 60) {
// End reconnecting after a specific timeout and flush all commands
// with a individual error
logger.debug('[Redis Strategy] - Time exhausted options:', options);
return new Error('Retry time exhausted');
}
if (options.attempt > 10) {
// End reconnecting with built in error
return undefined;
}
// reconnect after
return Math.min(options.attempt * 100, 3000);
}
});
client.on('connect', function () {
console.log('Redis client connected');
});
client.on('error', function (err) {
console.log('Something went wrong ' + err);
});
рд╡рд╛рд╣, рд╡рд┐рд╢реНрд╡рд╛рд╕ рдирд╣реАрдВ рд╣реЛрддрд╛ рдХрд┐ рдореИрдВрдиреЗ рдЗрд╕ рд╡реНрдпрд╡рд╣рд╛рд░ рдкрд░ рдзреНрдпрд╛рди рдирд╣реАрдВ рджрд┐рдпрд╛ рд╣реИред
рдореИрдВ рдЕрдкрдиреЗ рдРрдкреНрд╕ рдХреЛ https://github.com/Unitech/pm2 рдХреЗ рд╕рд╛рде рдЪрд▓рд╛рддрд╛ рд╣реВрдВ, рдЬреЛ рдХрд┐ рд╡рд┐рдлрд▓рддрд╛ рд╣реЛрдиреЗ рдкрд░ рдРрдк рдХреЛ рдкреБрдирд░рд╛рд░рдВрдн рдХрд░рддрд╛ рд╣реИ, рдЗрд╕рд▓рд┐рдП рдпрд╣ рдХрд╛рдлреА рд╕рдордп рд╕реЗ рдХрд┐рд╕реА рдХрд╛ рдзреНрдпрд╛рди рдирд╣реАрдВ рдЧрдпрд╛ рд╣реИред
рд╢рд╛рдирджрд╛рд░ рдХреИрдЪ!
рдХреНрдпрд╛ рдкреБрдирд░реНрдирд╡реАрдиреАрдХрд░рдг рдХреЛ рдкреВрд░рд╛ рдХрд░рдиреЗ рдХрд╛ рдПрдХ рдФрд░ рддрд░реАрдХрд╛ рд╣реИ рдЬрдм рддрдХ рдХрд┐ рдпрд╣ рддрдп рдирд╣реАрдВ рд╣реЛ рдЬрд╛рддрд╛? (рдореИрдВ рджреЗрдЦ рд░рд╣рд╛ рд╣реВрдБ рдирд╡реАрдирддрдо рд░рд┐рд▓реАрдЬ 2 рд╕рд╛рд▓ рдкрд╣рд▓реЗ рд╣реИ)
рд╣рд╛рдБ, рд╣рдо рдЖрдИрдУрд░реНрдбрд┐рд╕ рд╣рд╛рд╣рд╛ рдореЗрдВ рдЪрд▓реЗ рдЧрдП
@ рд╕реЛрдВрдЯреЛ рдореИрдВ рд╕рд╣рдордд рд╣реВрдБ, рдореИрдВ рдЖрдЬ рдЖрдпреЛрдбрд┐рд╕ рдкрд░ рд╕реНрд╡рд┐рдЪ рдХрд░ рд░рд╣рд╛ рд╣реВрдБред рдпрд╣ рдЕрдзрд┐рдХ рдмрд╛рд░ рдЕрдкрдбреЗрдЯ рд╣реЛ рд░рд╣рд╛ рд╣реИ, рдЗрд╕рдореЗрдВ рдФрд░ рдЕрдзрд┐рдХ рд╡рд┐рд╢реЗрд╖рддрд╛рдПрдВ рд╣реИрдВ рдФрд░ рдпрд╣ fassttterr рд╣реИред
рдзрдиреНрдпрд╡рд╛рдж, рдпрд╣ рд╡рд╛рд╕реНрддрд╡ рдореЗрдВ рдмреЗрд╣рддрд░ рд▓рдЧрддрд╛ рд╣реИ, рдореИрдВ рдЗрд╕ рдкреБрд╕реНрддрдХрд╛рд▓рдп рд╕реЗ рдЕрдкрд░рд┐рдЪрд┐рдд рдерд╛ред
рдЗрд╕ рд╡рд░реНрддрдорд╛рди рдкрд░рд┐рдпреЛрдЬрдирд╛ рдХреЗ рд▓рд┐рдП рдЕрдирдлреЙрд░реНрдЪрдВрдЯрд▓реА рдореИрдВ рд╕реНрд╡рд┐рдЪ рдирд╣реАрдВ рдХрд░ рдкрд╛рдКрдВрдЧрд╛, рд▓реЗрдХрд┐рди рднрд╡рд┐рд╖реНрдп рдХреЗ рдХрд╛рдо рдХреЗ рд▓рд┐рдП рдпрд╣ рдЬрд╛рдирдирд╛ рдЕрдЪреНрдЫрд╛ рд╣реИред
рд╕рдмрд╕реЗ рдЙрдкрдпреЛрдЧреА рдЯрд┐рдкреНрдкрдгреА
рд╣рд╛рдБ, рд╣рдо рдЖрдИрдУрд░реНрдбрд┐рд╕ рд╣рд╛рд╣рд╛ рдореЗрдВ рдЪрд▓реЗ рдЧрдП