Compare commits

...

4 Commits

Author SHA1 Message Date
Julien Fontanet
03b28057ad wip 2024-08-08 13:49:58 +02:00
Julien Fontanet
04ed6406c1 wip 2024-08-08 13:49:58 +02:00
Julien Fontanet
f47ec95a38 wip 2024-08-08 13:49:58 +02:00
Julien Fontanet
091e20d635 WiP 2024-08-08 13:49:58 +02:00
4 changed files with 34 additions and 4 deletions

View File

@@ -138,7 +138,12 @@ ${APP_NAME} v${APP_VERSION}
// dont delay require to stopping phase because deps may no longer be there (eg on uninstall)
const { default: fromCallback } = await import('promise-toolbox/fromCallback')
app.hooks.on('stop', () => fromCallback(cb => httpServer.stop(cb)))
app.hooks.on('stop', async () => {
await fromCallback(cb => httpServer.stop(cb))
// idle connections will prevent xo-proxy from stopping
httpServer.closeIdleConnections()
})
await app.hooks.start()

View File

@@ -645,6 +645,7 @@ async function call(args) {
const baseUrl = xo._url.replace(/^ws/, 'http')
const httpOptions = {
rejectUnauthorized: !(await getServerConfig()).allowUnauthorized,
timeout: 0,
}
const result = await xo.call(method, params)

View File

@@ -5,6 +5,7 @@ import hrp from 'http-request-plus'
import isEmpty from 'lodash/isEmpty.js'
import omit from 'lodash/omit.js'
import parseSetCookie from 'set-cookie-parser'
import pRetry from 'promise-toolbox/retry'
import pumpify from 'pumpify'
import some from 'lodash/some.js'
import split2 from 'split2'
@@ -208,9 +209,32 @@ export default class Proxy {
await this.updateProxyAppliance(id, { upgrade: true })
} else {
// quick API upgrade
await this.callProxyMethod(id, 'appliance.updater.upgrade', undefined, {
const opts = {
timeout: this._app.config.getDuration('xo-proxy.xoaUpgradeTimeout'),
})
}
for (let i = 0; i < 3; ++i) {
console.log('call ', i)
try {
// the call can fail with ECONNRESET due to xoa-updater or xo-proxy restarting (due to a previous loop)
const result = await pRetry(() => this.callProxyMethod(id, 'appliance.updater.upgrade', undefined, opts), {
delay: 3e3,
tries: 20,
when: e => e.code === 'ECONNREFUSED' || e.message.includes('ECONNREFUSED'),
})
console.log('result', result)
} catch (error) {
console.log('error', error)
if (
// connection can break due to xoa-updater or xo-proxy restarting
!(error.code === 'ECONNRESET' || error.message.includes('ECONNRESET'))
) {
throw error
}
}
}
}
this.getProxyApplianceUpdaterState(REMOVE_CACHE_ENTRY, id)

View File

@@ -314,7 +314,7 @@ const Proxies = decorate([
console.warn('fetchProxyUpgrades', error)
}
this.state.fetchUpgradesTimeout = setTimeout(fetchProxyUpgrades, 30e3)
this.state.fetchUpgradesTimeout = setTimeout(fetchProxyUpgrades, 5e3)
},
async deployProxy({ fetchProxyUpgrades }, proxy) {
await deployProxy(proxy)