Add siad connection check
This commit is contained in:
parent
103a89bc98
commit
98b649702d
|
@ -49,6 +49,13 @@ export class Server {
|
||||||
this.app.listen(port, () => {
|
this.app.listen(port, () => {
|
||||||
this.logger.info(`Listening on port ${port}`)
|
this.logger.info(`Listening on port ${port}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.logger.info("Verifying connection to siad...")
|
||||||
|
this.verifyConnection().then((version: string | null) => {
|
||||||
|
if (version) {
|
||||||
|
this.logger.info(`siad reachable, version ${version}`)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private configureMiddleware() {
|
private configureMiddleware() {
|
||||||
|
@ -76,6 +83,17 @@ export class Server {
|
||||||
this.app.post("/linkfile", this.handleLinkfilePOST.bind(this))
|
this.app.post("/linkfile", this.handleLinkfilePOST.bind(this))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async verifyConnection(): Promise<string | null> {
|
||||||
|
try {
|
||||||
|
const resp = await siad.get('/daemon/version')
|
||||||
|
return resp.data.version
|
||||||
|
} catch (err) {
|
||||||
|
const { message } = err;
|
||||||
|
this.logger.error(message)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private handleSialinkGET() {
|
private handleSialinkGET() {
|
||||||
return proxy(`${SIAD_ENDPOINT}/renter/sialink`, {
|
return proxy(`${SIAD_ENDPOINT}/renter/sialink`, {
|
||||||
proxyReqOptDecorator: (opts, _) => {
|
proxyReqOptDecorator: (opts, _) => {
|
||||||
|
|
Reference in New Issue