mirror of
https://github.com/mempool/mempool.git
synced 2026-08-13 12:33:11 +02:00
clean up stale unix sockets
This commit is contained in:
parent
e9d6cf8c04
commit
402b3ba00f
1 changed files with 16 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import express from 'express';
|
||||
import { Application, Request, Response, NextFunction } from 'express';
|
||||
import * as fs from 'fs';
|
||||
import * as http from 'http';
|
||||
import * as WebSocket from 'ws';
|
||||
import bitcoinApi from './api/bitcoin/bitcoin-api-factory';
|
||||
|
|
@ -67,6 +68,10 @@ class Server {
|
|||
constructor() {
|
||||
this.app = express();
|
||||
|
||||
if (cluster.isPrimary && config.MEMPOOL.UNIX_SOCKET_PATH) {
|
||||
this.clearStaleUnixSocket(config.MEMPOOL.UNIX_SOCKET_PATH);
|
||||
}
|
||||
|
||||
if (!config.MEMPOOL.SPAWN_CLUSTER_PROCS) {
|
||||
void this.startServer();
|
||||
return;
|
||||
|
|
@ -249,6 +254,17 @@ class Server {
|
|||
void poolsUpdater.$startService();
|
||||
}
|
||||
|
||||
clearStaleUnixSocket(path: string): void {
|
||||
try {
|
||||
if (fs.existsSync(path)) {
|
||||
fs.unlinkSync(path);
|
||||
logger.notice(`Removed stale unix socket ${path}`);
|
||||
}
|
||||
} catch (e) {
|
||||
logger.err(`Failed to remove stale unix socket ${path}. Reason: ${e instanceof Error ? e.message : e}`);
|
||||
}
|
||||
}
|
||||
|
||||
/** @asyncSafe */
|
||||
async runMainUpdateLoop(): Promise<void> {
|
||||
const start = Date.now();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue