|
|
@ -1,4 +1,4 @@
|
|
|
|
(function(e, a) { for(var i in a) e[i] = a[i]; }(exports, /******/ (function(modules) { // webpackBootstrap
|
|
|
|
(function (e, a) { for (var i in a) e[i] = a[i]; }(exports, /******/(function (modules) { // webpackBootstrap
|
|
|
|
/******/ // The module cache
|
|
|
|
/******/ // The module cache
|
|
|
|
/******/ var installedModules = {};
|
|
|
|
/******/ var installedModules = {};
|
|
|
|
/******/
|
|
|
|
/******/
|
|
|
@ -6,15 +6,17 @@
|
|
|
|
/******/ function __webpack_require__(moduleId) {
|
|
|
|
/******/ function __webpack_require__(moduleId) {
|
|
|
|
/******/
|
|
|
|
/******/
|
|
|
|
/******/ // Check if module is in cache
|
|
|
|
/******/ // Check if module is in cache
|
|
|
|
/******/ if(installedModules[moduleId]) {
|
|
|
|
/******/ if (installedModules[moduleId]) {
|
|
|
|
/******/ return installedModules[moduleId].exports;
|
|
|
|
/******/ return installedModules[moduleId].exports;
|
|
|
|
/******/ }
|
|
|
|
/******/
|
|
|
|
|
|
|
|
}
|
|
|
|
/******/ // Create a new module (and put it into the cache)
|
|
|
|
/******/ // Create a new module (and put it into the cache)
|
|
|
|
/******/ var module = installedModules[moduleId] = {
|
|
|
|
/******/ var module = installedModules[moduleId] = {
|
|
|
|
/******/ i: moduleId,
|
|
|
|
/******/ i: moduleId,
|
|
|
|
/******/ l: false,
|
|
|
|
/******/ l: false,
|
|
|
|
/******/ exports: {}
|
|
|
|
/******/ exports: {}
|
|
|
|
/******/ };
|
|
|
|
/******/
|
|
|
|
|
|
|
|
};
|
|
|
|
/******/
|
|
|
|
/******/
|
|
|
|
/******/ // Execute the module function
|
|
|
|
/******/ // Execute the module function
|
|
|
|
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
|
|
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
|
@ -24,7 +26,8 @@
|
|
|
|
/******/
|
|
|
|
/******/
|
|
|
|
/******/ // Return the exports of the module
|
|
|
|
/******/ // Return the exports of the module
|
|
|
|
/******/ return module.exports;
|
|
|
|
/******/ return module.exports;
|
|
|
|
/******/ }
|
|
|
|
/******/
|
|
|
|
|
|
|
|
}
|
|
|
|
/******/
|
|
|
|
/******/
|
|
|
|
/******/
|
|
|
|
/******/
|
|
|
|
/******/ // expose the modules object (__webpack_modules__)
|
|
|
|
/******/ // expose the modules object (__webpack_modules__)
|
|
|
@ -34,47 +37,53 @@
|
|
|
|
/******/ __webpack_require__.c = installedModules;
|
|
|
|
/******/ __webpack_require__.c = installedModules;
|
|
|
|
/******/
|
|
|
|
/******/
|
|
|
|
/******/ // define getter function for harmony exports
|
|
|
|
/******/ // define getter function for harmony exports
|
|
|
|
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
|
|
/******/ __webpack_require__.d = function (exports, name, getter) {
|
|
|
|
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
|
|
/******/ if (!__webpack_require__.o(exports, name)) {
|
|
|
|
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
|
|
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
|
|
/******/ }
|
|
|
|
/******/
|
|
|
|
/******/ };
|
|
|
|
}
|
|
|
|
|
|
|
|
/******/
|
|
|
|
|
|
|
|
};
|
|
|
|
/******/
|
|
|
|
/******/
|
|
|
|
/******/ // define __esModule on exports
|
|
|
|
/******/ // define __esModule on exports
|
|
|
|
/******/ __webpack_require__.r = function(exports) {
|
|
|
|
/******/ __webpack_require__.r = function (exports) {
|
|
|
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
|
|
/******/ if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
|
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
|
/******/ }
|
|
|
|
/******/
|
|
|
|
|
|
|
|
}
|
|
|
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
|
/******/ };
|
|
|
|
/******/
|
|
|
|
|
|
|
|
};
|
|
|
|
/******/
|
|
|
|
/******/
|
|
|
|
/******/ // create a fake namespace object
|
|
|
|
/******/ // create a fake namespace object
|
|
|
|
/******/ // mode & 1: value is a module id, require it
|
|
|
|
/******/ // mode & 1: value is a module id, require it
|
|
|
|
/******/ // mode & 2: merge all properties of value into the ns
|
|
|
|
/******/ // mode & 2: merge all properties of value into the ns
|
|
|
|
/******/ // mode & 4: return value when already ns object
|
|
|
|
/******/ // mode & 4: return value when already ns object
|
|
|
|
/******/ // mode & 8|1: behave like require
|
|
|
|
/******/ // mode & 8|1: behave like require
|
|
|
|
/******/ __webpack_require__.t = function(value, mode) {
|
|
|
|
/******/ __webpack_require__.t = function (value, mode) {
|
|
|
|
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
|
|
/******/ if (mode & 1) value = __webpack_require__(value);
|
|
|
|
/******/ if(mode & 8) return value;
|
|
|
|
/******/ if (mode & 8) return value;
|
|
|
|
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
|
|
/******/ if ((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
|
|
/******/ var ns = Object.create(null);
|
|
|
|
/******/ var ns = Object.create(null);
|
|
|
|
/******/ __webpack_require__.r(ns);
|
|
|
|
/******/ __webpack_require__.r(ns);
|
|
|
|
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
|
|
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
|
|
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
|
|
/******/ if (mode & 2 && typeof value != 'string') for (var key in value) __webpack_require__.d(ns, key, function (key) { return value[key]; }.bind(null, key));
|
|
|
|
/******/ return ns;
|
|
|
|
/******/ return ns;
|
|
|
|
/******/ };
|
|
|
|
/******/
|
|
|
|
|
|
|
|
};
|
|
|
|
/******/
|
|
|
|
/******/
|
|
|
|
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
|
|
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
|
|
/******/ __webpack_require__.n = function(module) {
|
|
|
|
/******/ __webpack_require__.n = function (module) {
|
|
|
|
/******/ var getter = module && module.__esModule ?
|
|
|
|
/******/ var getter = module && module.__esModule ?
|
|
|
|
/******/ function getDefault() { return module['default']; } :
|
|
|
|
/******/ function getDefault() { return module['default']; } :
|
|
|
|
/******/ function getModuleExports() { return module; };
|
|
|
|
/******/ function getModuleExports() { return module; };
|
|
|
|
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
|
|
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
|
|
/******/ return getter;
|
|
|
|
/******/ return getter;
|
|
|
|
/******/ };
|
|
|
|
/******/
|
|
|
|
|
|
|
|
};
|
|
|
|
/******/
|
|
|
|
/******/
|
|
|
|
/******/ // Object.prototype.hasOwnProperty.call
|
|
|
|
/******/ // Object.prototype.hasOwnProperty.call
|
|
|
|
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
|
|
/******/ __webpack_require__.o = function (object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
|
|
/******/
|
|
|
|
/******/
|
|
|
|
/******/ // __webpack_public_path__
|
|
|
|
/******/ // __webpack_public_path__
|
|
|
|
/******/ __webpack_require__.p = "";
|
|
|
|
/******/ __webpack_require__.p = "";
|
|
|
@ -82,40 +91,42 @@
|
|
|
|
/******/
|
|
|
|
/******/
|
|
|
|
/******/ // Load entry module and return exports
|
|
|
|
/******/ // Load entry module and return exports
|
|
|
|
/******/ return __webpack_require__(__webpack_require__.s = 0);
|
|
|
|
/******/ return __webpack_require__(__webpack_require__.s = 0);
|
|
|
|
/******/ })
|
|
|
|
/******/
|
|
|
|
|
|
|
|
})
|
|
|
|
/************************************************************************/
|
|
|
|
/************************************************************************/
|
|
|
|
/******/ ([
|
|
|
|
/******/([
|
|
|
|
/* 0 */
|
|
|
|
/* 0 */
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
/***/ (function (module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = __webpack_require__(1);
|
|
|
|
module.exports = __webpack_require__(1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/
|
|
|
|
|
|
|
|
}),
|
|
|
|
/* 1 */
|
|
|
|
/* 1 */
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
/***/ (function (module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
exports.__esModule = true;
|
|
|
|
exports.__esModule = true;
|
|
|
|
// Limit dependencies to core Node modules. This means the code in this file has to be very low-level and unattractive,
|
|
|
|
// Limit dependencies to core Node modules. This means the code in this file has to be very low-level and unattractive,
|
|
|
|
// but simplifies things for the consumer of this module.
|
|
|
|
// but simplifies things for the consumer of this module.
|
|
|
|
__webpack_require__(2);
|
|
|
|
__webpack_require__(2);
|
|
|
|
var net = __webpack_require__(3);
|
|
|
|
var net = __webpack_require__(3);
|
|
|
|
var path = __webpack_require__(4);
|
|
|
|
var path = __webpack_require__(4);
|
|
|
|
var readline = __webpack_require__(5);
|
|
|
|
var readline = __webpack_require__(5);
|
|
|
|
var ArgsUtil_1 = __webpack_require__(6);
|
|
|
|
var ArgsUtil_1 = __webpack_require__(6);
|
|
|
|
var ExitWhenParentExits_1 = __webpack_require__(7);
|
|
|
|
var ExitWhenParentExits_1 = __webpack_require__(7);
|
|
|
|
var virtualConnectionServer = __webpack_require__(8);
|
|
|
|
var virtualConnectionServer = __webpack_require__(8);
|
|
|
|
// Webpack doesn't support dynamic requires for files not present at compile time, so grab a direct
|
|
|
|
// Webpack doesn't support dynamic requires for files not present at compile time, so grab a direct
|
|
|
|
// reference to Node's runtime 'require' function.
|
|
|
|
// reference to Node's runtime 'require' function.
|
|
|
|
var dynamicRequire = eval('require');
|
|
|
|
var dynamicRequire = eval('require');
|
|
|
|
// Signal to the .NET side when we're ready to accept invocations
|
|
|
|
// Signal to the .NET side when we're ready to accept invocations
|
|
|
|
var server = net.createServer().on('listening', function () {
|
|
|
|
var server = net.createServer().on('listening', function () {
|
|
|
|
console.log('[Microsoft.AspNetCore.NodeServices:Listening]');
|
|
|
|
console.log('[Microsoft.AspNetCore.NodeServices:Listening]');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
// Each virtual connection represents a separate invocation
|
|
|
|
// Each virtual connection represents a separate invocation
|
|
|
|
virtualConnectionServer.createInterface(server).on('connection', function (connection) {
|
|
|
|
virtualConnectionServer.createInterface(server).on('connection', function (connection) {
|
|
|
|
readline.createInterface(connection, null).on('line', function (line) {
|
|
|
|
readline.createInterface(connection, null).on('line', function (line) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// Get a reference to the function to invoke
|
|
|
|
// Get a reference to the function to invoke
|
|
|
@ -154,39 +165,40 @@ virtualConnectionServer.createInterface(server).on('connection', function (conne
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
// Begin listening now. The underlying transport varies according to the runtime platform.
|
|
|
|
// Begin listening now. The underlying transport varies according to the runtime platform.
|
|
|
|
// On Windows it's Named Pipes; on Linux/OSX it's Domain Sockets.
|
|
|
|
// On Windows it's Named Pipes; on Linux/OSX it's Domain Sockets.
|
|
|
|
var useWindowsNamedPipes = /^win/.test(process.platform);
|
|
|
|
var useWindowsNamedPipes = /^win/.test(process.platform);
|
|
|
|
var parsedArgs = ArgsUtil_1.parseArgs(process.argv);
|
|
|
|
var parsedArgs = ArgsUtil_1.parseArgs(process.argv);
|
|
|
|
var listenAddress = (useWindowsNamedPipes ? '\\\\.\\pipe\\' : '/tmp/') + parsedArgs.listenAddress;
|
|
|
|
var listenAddress = (useWindowsNamedPipes ? '\\\\.\\pipe\\' : '/tmp/') + parsedArgs.listenAddress;
|
|
|
|
server.listen(listenAddress);
|
|
|
|
server.listen(listenAddress);
|
|
|
|
ExitWhenParentExits_1.exitWhenParentExits(parseInt(parsedArgs.parentPid), /* ignoreSigint */ true);
|
|
|
|
ExitWhenParentExits_1.exitWhenParentExits(parseInt(parsedArgs.parentPid), /* ignoreSigint */ true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/
|
|
|
|
|
|
|
|
}),
|
|
|
|
/* 2 */
|
|
|
|
/* 2 */
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
/***/ (function (module, exports) {
|
|
|
|
|
|
|
|
|
|
|
|
// When Node writes to stdout/strerr, we capture that and convert the lines into calls on the
|
|
|
|
// When Node writes to stdout/strerr, we capture that and convert the lines into calls on the
|
|
|
|
// active .NET ILogger. But by default, stdout/stderr don't have any way of distinguishing
|
|
|
|
// active .NET ILogger. But by default, stdout/stderr don't have any way of distinguishing
|
|
|
|
// linebreaks inside log messages from the linebreaks that delimit separate log messages,
|
|
|
|
// linebreaks inside log messages from the linebreaks that delimit separate log messages,
|
|
|
|
// so multiline strings will end up being written to the ILogger as multiple independent
|
|
|
|
// so multiline strings will end up being written to the ILogger as multiple independent
|
|
|
|
// log messages. This makes them very hard to make sense of, especially when they represent
|
|
|
|
// log messages. This makes them very hard to make sense of, especially when they represent
|
|
|
|
// something like stack traces.
|
|
|
|
// something like stack traces.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// To fix this, we intercept stdout/stderr writes, and replace internal linebreaks with a
|
|
|
|
// To fix this, we intercept stdout/stderr writes, and replace internal linebreaks with a
|
|
|
|
// marker token. When .NET receives the lines, it converts the marker tokens back to regular
|
|
|
|
// marker token. When .NET receives the lines, it converts the marker tokens back to regular
|
|
|
|
// linebreaks within the logged messages.
|
|
|
|
// linebreaks within the logged messages.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Note that it's better to do the interception at the stdout/stderr level, rather than at
|
|
|
|
// Note that it's better to do the interception at the stdout/stderr level, rather than at
|
|
|
|
// the console.log/console.error (etc.) level, because this takes place after any native
|
|
|
|
// the console.log/console.error (etc.) level, because this takes place after any native
|
|
|
|
// message formatting has taken place (e.g., inserting values for % placeholders).
|
|
|
|
// message formatting has taken place (e.g., inserting values for % placeholders).
|
|
|
|
var findInternalNewlinesRegex = /\n(?!$)/g;
|
|
|
|
var findInternalNewlinesRegex = /\n(?!$)/g;
|
|
|
|
var encodedNewline = '__ns_newline__';
|
|
|
|
var encodedNewline = '__ns_newline__';
|
|
|
|
encodeNewlinesWrittenToStream(process.stdout);
|
|
|
|
encodeNewlinesWrittenToStream(process.stdout);
|
|
|
|
encodeNewlinesWrittenToStream(process.stderr);
|
|
|
|
encodeNewlinesWrittenToStream(process.stderr);
|
|
|
|
function encodeNewlinesWrittenToStream(outputStream) {
|
|
|
|
function encodeNewlinesWrittenToStream(outputStream) {
|
|
|
|
var origWriteFunction = outputStream.write;
|
|
|
|
var origWriteFunction = outputStream.write;
|
|
|
|
outputStream.write = function (value) {
|
|
|
|
outputStream.write = function (value) {
|
|
|
|
// Only interfere with the write if it's definitely a string
|
|
|
|
// Only interfere with the write if it's definitely a string
|
|
|
@ -199,38 +211,42 @@ function encodeNewlinesWrittenToStream(outputStream) {
|
|
|
|
origWriteFunction.apply(this, arguments);
|
|
|
|
origWriteFunction.apply(this, arguments);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function encodeNewlinesInString(str) {
|
|
|
|
function encodeNewlinesInString(str) {
|
|
|
|
return str.replace(findInternalNewlinesRegex, encodedNewline);
|
|
|
|
return str.replace(findInternalNewlinesRegex, encodedNewline);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/
|
|
|
|
|
|
|
|
}),
|
|
|
|
/* 3 */
|
|
|
|
/* 3 */
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
/***/ (function (module, exports) {
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = require("net");
|
|
|
|
module.exports = require("net");
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/
|
|
|
|
|
|
|
|
}),
|
|
|
|
/* 4 */
|
|
|
|
/* 4 */
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
/***/ (function (module, exports) {
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = require("path");
|
|
|
|
module.exports = require("path");
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/
|
|
|
|
|
|
|
|
}),
|
|
|
|
/* 5 */
|
|
|
|
/* 5 */
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
/***/ (function (module, exports) {
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = require("readline");
|
|
|
|
module.exports = require("readline");
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/
|
|
|
|
|
|
|
|
}),
|
|
|
|
/* 6 */
|
|
|
|
/* 6 */
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
/***/ (function (module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
exports.__esModule = true;
|
|
|
|
exports.__esModule = true;
|
|
|
|
function parseArgs(args) {
|
|
|
|
function parseArgs(args) {
|
|
|
|
// Very simplistic parsing which is sufficient for the cases needed. We don't want to bring in any external
|
|
|
|
// Very simplistic parsing which is sufficient for the cases needed. We don't want to bring in any external
|
|
|
|
// dependencies (such as an args-parsing library) to this file.
|
|
|
|
// dependencies (such as an args-parsing library) to this file.
|
|
|
|
var result = {};
|
|
|
|
var result = {};
|
|
|
@ -247,27 +263,28 @@ function parseArgs(args) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.parseArgs = parseArgs;
|
|
|
|
exports.parseArgs = parseArgs;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/
|
|
|
|
|
|
|
|
}),
|
|
|
|
/* 7 */
|
|
|
|
/* 7 */
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
/***/ (function (module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
In general, we want the Node child processes to be terminated as soon as the parent .NET processes exit,
|
|
|
|
In general, we want the Node child processes to be terminated as soon as the parent .NET processes exit,
|
|
|
|
because we have no further use for them. If the .NET process shuts down gracefully, it will run its
|
|
|
|
because we have no further use for them. If the .NET process shuts down gracefully, it will run its
|
|
|
|
finalizers, one of which (in OutOfProcessNodeInstance.cs) will kill its associated Node process immediately.
|
|
|
|
finalizers, one of which (in OutOfProcessNodeInstance.cs) will kill its associated Node process immediately.
|
|
|
|
|
|
|
|
|
|
|
|
But if the .NET process is terminated forcefully (e.g., on Linux/OSX with 'kill -9'), then it won't have
|
|
|
|
But if the .NET process is terminated forcefully (e.g., on Linux/OSX with 'kill -9'), then it won't have
|
|
|
|
any opportunity to shut down its child processes, and by default they will keep running. In this case, it's
|
|
|
|
any opportunity to shut down its child processes, and by default they will keep running. In this case, it's
|
|
|
|
up to the child process to detect this has happened and terminate itself.
|
|
|
|
up to the child process to detect this has happened and terminate itself.
|
|
|
|
|
|
|
|
|
|
|
|
There are many possible approaches to detecting when a parent process has exited, most of which behave
|
|
|
|
There are many possible approaches to detecting when a parent process has exited, most of which behave
|
|
|
|
differently between Windows and Linux/OS X:
|
|
|
|
differently between Windows and Linux/OS X:
|
|
|
|
|
|
|
|
|
|
|
|
- On Windows, the parent process can mark its child as being a 'job' that should auto-terminate when
|
|
|
|
- On Windows, the parent process can mark its child as being a 'job' that should auto-terminate when
|
|
|
|
the parent does (http://stackoverflow.com/a/4657392). Not cross-platform.
|
|
|
|
the parent does (http://stackoverflow.com/a/4657392). Not cross-platform.
|
|
|
@ -287,12 +304,12 @@ differently between Windows and Linux/OS X:
|
|
|
|
process.stdout is still connected (without actually writing to it) but I haven't found any property whose
|
|
|
|
process.stdout is still connected (without actually writing to it) but I haven't found any property whose
|
|
|
|
value changes until you actually try to write to it.
|
|
|
|
value changes until you actually try to write to it.
|
|
|
|
|
|
|
|
|
|
|
|
Of these, the only cross-platform approach that is actually documented as a valid strategy is simply polling
|
|
|
|
Of these, the only cross-platform approach that is actually documented as a valid strategy is simply polling
|
|
|
|
to check whether the parent PID is still running. So that's what we do here.
|
|
|
|
to check whether the parent PID is still running. So that's what we do here.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
exports.__esModule = true;
|
|
|
|
exports.__esModule = true;
|
|
|
|
var pollIntervalMs = 1000;
|
|
|
|
var pollIntervalMs = 1000;
|
|
|
|
function exitWhenParentExits(parentPid, ignoreSigint) {
|
|
|
|
function exitWhenParentExits(parentPid, ignoreSigint) {
|
|
|
|
setInterval(function () {
|
|
|
|
setInterval(function () {
|
|
|
|
if (!processExists(parentPid)) {
|
|
|
|
if (!processExists(parentPid)) {
|
|
|
|
// Can't log anything at this point, because out stdout was connected to the parent,
|
|
|
|
// Can't log anything at this point, because out stdout was connected to the parent,
|
|
|
@ -318,9 +335,9 @@ function exitWhenParentExits(parentPid, ignoreSigint) {
|
|
|
|
console.log('Received SIGINT. Waiting for .NET process to exit...');
|
|
|
|
console.log('Received SIGINT. Waiting for .NET process to exit...');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.exitWhenParentExits = exitWhenParentExits;
|
|
|
|
exports.exitWhenParentExits = exitWhenParentExits;
|
|
|
|
function processExists(pid) {
|
|
|
|
function processExists(pid) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// Sending signal 0 - on all platforms - tests whether the process exists. As long as it doesn't
|
|
|
|
// Sending signal 0 - on all platforms - tests whether the process exists. As long as it doesn't
|
|
|
|
// throw, that means it does exist.
|
|
|
|
// throw, that means it does exist.
|
|
|
@ -335,27 +352,28 @@ function processExists(pid) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/
|
|
|
|
|
|
|
|
}),
|
|
|
|
/* 8 */
|
|
|
|
/* 8 */
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
/***/ (function (module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
exports.__esModule = true;
|
|
|
|
exports.__esModule = true;
|
|
|
|
var events_1 = __webpack_require__(9);
|
|
|
|
var events_1 = __webpack_require__(9);
|
|
|
|
var VirtualConnection_1 = __webpack_require__(10);
|
|
|
|
var VirtualConnection_1 = __webpack_require__(10);
|
|
|
|
// Keep this in sync with the equivalent constant in the .NET code. Both sides split up their transmissions into frames with this max length,
|
|
|
|
// Keep this in sync with the equivalent constant in the .NET code. Both sides split up their transmissions into frames with this max length,
|
|
|
|
// and both will reject longer frames.
|
|
|
|
// and both will reject longer frames.
|
|
|
|
var MaxFrameBodyLength = 16 * 1024;
|
|
|
|
var MaxFrameBodyLength = 16 * 1024;
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Accepts connections to a net.Server and adapts them to behave as multiplexed connections. That is, for each physical socket connection,
|
|
|
|
* Accepts connections to a net.Server and adapts them to behave as multiplexed connections. That is, for each physical socket connection,
|
|
|
|
* we track a list of 'virtual connections' whose API is a Duplex stream. The remote clients may open and close as many virtual connections
|
|
|
|
* we track a list of 'virtual connections' whose API is a Duplex stream. The remote clients may open and close as many virtual connections
|
|
|
|
* as they wish, reading and writing to them independently, without the overhead of establishing new physical connections each time.
|
|
|
|
* as they wish, reading and writing to them independently, without the overhead of establishing new physical connections each time.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function createInterface(server) {
|
|
|
|
function createInterface(server) {
|
|
|
|
var emitter = new events_1.EventEmitter();
|
|
|
|
var emitter = new events_1.EventEmitter();
|
|
|
|
server.on('connection', function (socket) {
|
|
|
|
server.on('connection', function (socket) {
|
|
|
|
// For each physical socket connection, maintain a set of virtual connections. Issue a notification whenever
|
|
|
|
// For each physical socket connection, maintain a set of virtual connections. Issue a notification whenever
|
|
|
@ -365,12 +383,12 @@ function createInterface(server) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return emitter;
|
|
|
|
return emitter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.createInterface = createInterface;
|
|
|
|
exports.createInterface = createInterface;
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Tracks the 'virtual connections' associated with a single physical socket connection.
|
|
|
|
* Tracks the 'virtual connections' associated with a single physical socket connection.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
var VirtualConnectionsCollection = /** @class */ (function () {
|
|
|
|
var VirtualConnectionsCollection = /** @class */ (function () {
|
|
|
|
function VirtualConnectionsCollection(_socket, _onVirtualConnectionCallback) {
|
|
|
|
function VirtualConnectionsCollection(_socket, _onVirtualConnectionCallback) {
|
|
|
|
var _this = this;
|
|
|
|
var _this = this;
|
|
|
|
this._socket = _socket;
|
|
|
|
this._socket = _socket;
|
|
|
@ -452,7 +470,7 @@ var VirtualConnectionsCollection = /** @class */ (function () {
|
|
|
|
newVirtualConnection.on('finish', function () {
|
|
|
|
newVirtualConnection.on('finish', function () {
|
|
|
|
// The virtual connection was closed locally. Clean up locally, and notify the remote that we're done.
|
|
|
|
// The virtual connection was closed locally. Clean up locally, and notify the remote that we're done.
|
|
|
|
_this._onVirtualConnectionWasClosed(header.connectionIdString);
|
|
|
|
_this._onVirtualConnectionWasClosed(header.connectionIdString);
|
|
|
|
_this._sendFrame(header.connectionIdBinary, new Buffer(0));
|
|
|
|
_this._sendFrame(header.connectionIdBinary, Buffer.alloc(0));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this._virtualConnections[header.connectionIdString] = newVirtualConnection;
|
|
|
|
this._virtualConnections[header.connectionIdString] = newVirtualConnection;
|
|
|
|
this._onVirtualConnectionCallback(newVirtualConnection);
|
|
|
|
this._onVirtualConnectionCallback(newVirtualConnection);
|
|
|
@ -514,7 +532,7 @@ var VirtualConnectionsCollection = /** @class */ (function () {
|
|
|
|
* Sends a number serialized in the correct format for .NET to receive as a System.Int32
|
|
|
|
* Sends a number serialized in the correct format for .NET to receive as a System.Int32
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
VirtualConnectionsCollection.prototype._sendInt32LE = function (value, callback) {
|
|
|
|
VirtualConnectionsCollection.prototype._sendInt32LE = function (value, callback) {
|
|
|
|
var buf = new Buffer(4);
|
|
|
|
var buf = Buffer.alloc(4);
|
|
|
|
buf.writeInt32LE(value, 0);
|
|
|
|
buf.writeInt32LE(value, 0);
|
|
|
|
this._socket.write(buf, callback);
|
|
|
|
this._socket.write(buf, callback);
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -524,22 +542,24 @@ var VirtualConnectionsCollection = /** @class */ (function () {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
return VirtualConnectionsCollection;
|
|
|
|
return VirtualConnectionsCollection;
|
|
|
|
}());
|
|
|
|
}());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/
|
|
|
|
|
|
|
|
}),
|
|
|
|
/* 9 */
|
|
|
|
/* 9 */
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
/***/ (function (module, exports) {
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = require("events");
|
|
|
|
module.exports = require("events");
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/
|
|
|
|
|
|
|
|
}),
|
|
|
|
/* 10 */
|
|
|
|
/* 10 */
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
/***/ (function (module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
var __extends = (this && this.__extends) || (function () {
|
|
|
|
var __extends = (this && this.__extends) || (function () {
|
|
|
|
var extendStatics = function (d, b) {
|
|
|
|
var extendStatics = function (d, b) {
|
|
|
|
extendStatics = Object.setPrototypeOf ||
|
|
|
|
extendStatics = Object.setPrototypeOf ||
|
|
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
|
@ -551,13 +571,13 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
|
function __() { this.constructor = d; }
|
|
|
|
function __() { this.constructor = d; }
|
|
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
|
|
};
|
|
|
|
};
|
|
|
|
})();
|
|
|
|
})();
|
|
|
|
exports.__esModule = true;
|
|
|
|
exports.__esModule = true;
|
|
|
|
var stream_1 = __webpack_require__(11);
|
|
|
|
var stream_1 = __webpack_require__(11);
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Represents a virtual connection. Multiple virtual connections may be multiplexed over a single physical socket connection.
|
|
|
|
* Represents a virtual connection. Multiple virtual connections may be multiplexed over a single physical socket connection.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
var VirtualConnection = /** @class */ (function (_super) {
|
|
|
|
var VirtualConnection = /** @class */ (function (_super) {
|
|
|
|
__extends(VirtualConnection, _super);
|
|
|
|
__extends(VirtualConnection, _super);
|
|
|
|
function VirtualConnection(_beginWriteCallback) {
|
|
|
|
function VirtualConnection(_beginWriteCallback) {
|
|
|
|
var _this = _super.call(this) || this;
|
|
|
|
var _this = _super.call(this) || this;
|
|
|
@ -577,7 +597,7 @@ var VirtualConnection = /** @class */ (function (_super) {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
VirtualConnection.prototype._write = function (chunk, encodingIfString, callback) {
|
|
|
|
VirtualConnection.prototype._write = function (chunk, encodingIfString, callback) {
|
|
|
|
if (typeof chunk === 'string') {
|
|
|
|
if (typeof chunk === 'string') {
|
|
|
|
chunk = new Buffer(chunk, encodingIfString);
|
|
|
|
chunk = Buffer.from(chunk, encodingIfString);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this._beginWriteCallback(chunk, callback);
|
|
|
|
this._beginWriteCallback(chunk, callback);
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -590,15 +610,17 @@ var VirtualConnection = /** @class */ (function (_super) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
return VirtualConnection;
|
|
|
|
return VirtualConnection;
|
|
|
|
}(stream_1.Duplex));
|
|
|
|
}(stream_1.Duplex));
|
|
|
|
exports.VirtualConnection = VirtualConnection;
|
|
|
|
exports.VirtualConnection = VirtualConnection;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/
|
|
|
|
|
|
|
|
}),
|
|
|
|
/* 11 */
|
|
|
|
/* 11 */
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
/***/ (function (module, exports) {
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = require("stream");
|
|
|
|
module.exports = require("stream");
|
|
|
|
|
|
|
|
|
|
|
|
/***/ })
|
|
|
|
/***/
|
|
|
|
/******/ ])));
|
|
|
|
})
|
|
|
|
|
|
|
|
/******/])));
|
|
|
|