Skip to content

Commit af8d228

Browse files
miira42indexzero
authored andcommitted
fixes EACCESS error with .sock (UNIX domain sockets) on Windows. Uses named pipes instead.
1 parent eecf6a2 commit af8d228

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

lib/forever.js

+5
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ function getAllProcesses(callback) {
9898
var fullPath = path.join(sockPath, name),
9999
socket = new nssocket.NsSocket();
100100

101+
if (process.platform === 'win32') {
102+
// it needs the prefix
103+
fullPath = '\\\\.\\pipe\\' + fullPath;
104+
}
105+
101106
socket.connect(fullPath, function (err) {
102107
if (err) {
103108
next(err);

lib/forever/worker.js

+25
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ Worker.prototype.start = function (callback) {
7171
self.exitOnStop && process.exit();
7272
});
7373

74+
if (process.platform === 'win32') {
75+
//
76+
// On Windows, delete the 'symbolic' sock file. This
77+
// file is used for exploration during `forever list`
78+
// as a mapping to the `\\.pipe\\*` "files" that can't
79+
// be enumerated because ... Windows.
80+
//
81+
fs.unlink(self._sockFile);
82+
}
83+
7484
self.monitor.stop();
7585
});
7686

@@ -110,6 +120,21 @@ Worker.prototype.start = function (callback) {
110120
'sock'
111121
].join('.'));
112122

123+
if (process.platform === 'win32') {
124+
//
125+
// Create 'symbolic' file on the system, so it can be later
126+
// found via "forever list" since the `\\.pipe\\*` "files" can't
127+
// be enumerated because ... Windows.
128+
//
129+
fs.openSync(sock, 'w');
130+
131+
//
132+
// It needs the prefix, otherwise EACCESS error happens on Windows
133+
// (no .sock extension, only named pipes with .pipe prefixes)
134+
//
135+
sock = '\\\\.\\pipe\\' + sock;
136+
}
137+
113138
self._socket.listen(sock);
114139
}
115140

0 commit comments

Comments
 (0)