Skip to content

Commit

Permalink
fixes EACCESS error with .sock (UNIX domain sockets) on Windows. Uses…
Browse files Browse the repository at this point in the history
… named pipes instead.
  • Loading branch information
miira42 authored and indexzero committed Oct 30, 2014
1 parent eecf6a2 commit af8d228
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/forever.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ function getAllProcesses(callback) {
var fullPath = path.join(sockPath, name),
socket = new nssocket.NsSocket();

if (process.platform === 'win32') {
// it needs the prefix
fullPath = '\\\\.\\pipe\\' + fullPath;
}

socket.connect(fullPath, function (err) {
if (err) {
next(err);
Expand Down
25 changes: 25 additions & 0 deletions lib/forever/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ Worker.prototype.start = function (callback) {
self.exitOnStop && process.exit();
});

if (process.platform === 'win32') {
//
// On Windows, delete the 'symbolic' sock file. This
// file is used for exploration during `forever list`
// as a mapping to the `\\.pipe\\*` "files" that can't
// be enumerated because ... Windows.
//
fs.unlink(self._sockFile);
}

self.monitor.stop();
});

Expand Down Expand Up @@ -110,6 +120,21 @@ Worker.prototype.start = function (callback) {
'sock'
].join('.'));

if (process.platform === 'win32') {
//
// Create 'symbolic' file on the system, so it can be later
// found via "forever list" since the `\\.pipe\\*` "files" can't
// be enumerated because ... Windows.
//
fs.openSync(sock, 'w');

//
// It needs the prefix, otherwise EACCESS error happens on Windows
// (no .sock extension, only named pipes with .pipe prefixes)
//
sock = '\\\\.\\pipe\\' + sock;
}

self._socket.listen(sock);
}

Expand Down

0 comments on commit af8d228

Please sign in to comment.