Skip to content

Commit

Permalink
fix(socket): only delete socket if current process is primary one (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
resure authored Sep 14, 2023
1 parent 30b08fe commit 592a048
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/expresskit.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import cluster from 'cluster';
import fs from 'fs';
import type {Server} from 'http';

Expand Down Expand Up @@ -44,7 +45,12 @@ export class ExpressKit {

this.nodekit.ctx.log(`Listening on ${listenTargetType} ${listenTarget}`);

if (appSocket && listenTargetType === 'socket' && fs.existsSync(appSocket)) {
if (
appSocket &&
listenTargetType === 'socket' &&
cluster.isPrimary &&
fs.existsSync(appSocket)
) {
fs.unlinkSync(appSocket);
}

Expand Down

0 comments on commit 592a048

Please sign in to comment.