log when using default pipe
This commit is contained in:
parent
8980e5a785
commit
a98bd306f3
|
@ -387,16 +387,15 @@ function serveControls() {
|
|||
|
||||
res.end('{"error":{"message":"unrecognized rpc"}}');
|
||||
});
|
||||
var pipename = common.pipename(state.config);
|
||||
var fs = require('fs');
|
||||
if (fs.existsSync(pipename)) {
|
||||
fs.unlinkSync(pipename);
|
||||
if (fs.existsSync(state._ipc.path)) {
|
||||
fs.unlinkSync(state._ipc.path);
|
||||
}
|
||||
// mask is so that processes owned by other users
|
||||
// can speak to this process, which is probably root-owned
|
||||
var oldUmask = process.umask(0x0000);
|
||||
controlServer.listen({
|
||||
path: pipename
|
||||
path: state._ipc.path
|
||||
, writableAll: true
|
||||
, readableAll: true
|
||||
, exclusive: false
|
||||
|
@ -443,6 +442,10 @@ function parseConfig(err, text) {
|
|||
}
|
||||
|
||||
state.config = camelCopy(config);
|
||||
state._ipc = common.pipename(state.config, true);
|
||||
if (!state.config.sock) {
|
||||
console.info('(' + state._ipc.comment + ': ' + state._ipc.path + ')');
|
||||
}
|
||||
if (state.config.token && token) {
|
||||
console.warn();
|
||||
console.warn("Found two tokens:");
|
||||
|
|
|
@ -10,14 +10,21 @@ var homedir = os.homedir();
|
|||
var localshare = '.local/share/telebit';
|
||||
var localconf = '.config/telebit';
|
||||
|
||||
common.pipename = function (config) {
|
||||
var pipename = (config.sock || common.DEFAULT_SOCK_NAME);
|
||||
if (/^win/i.test(os.platform())) {
|
||||
pipename = '\\\\?\\pipe' + pipename.replace(/\//, '\\');
|
||||
}
|
||||
return pipename;
|
||||
common.pipename = function (config, newApi) {
|
||||
var _ipc = {
|
||||
path: (config.sock || common.DEFAULT_SOCK_NAME)
|
||||
, comment: (/^win/i.test(os.platform()) ? 'windows pipe' : 'unix socket')
|
||||
, type: (/^win/i.test(os.platform()) ? 'pipe' : 'socket')
|
||||
};
|
||||
common.DEFAULT_SOCK_NAME = path.join(homedir, localshare, 'var', 'telebit.sock');
|
||||
if ('pipe' === _ipc.type) {
|
||||
_ipc.path = '\\\\?\\pipe' + pipename.replace(/\//, '\\');
|
||||
}
|
||||
if (newApi) {
|
||||
return _ipc;
|
||||
}
|
||||
return _ipc.path;
|
||||
};
|
||||
common.DEFAULT_SOCK_NAME = path.join(homedir, localshare, 'var', 'run', 'telebit.sock');
|
||||
|
||||
try {
|
||||
mkdirp.sync(path.join(__dirname, '..', 'var', 'log'));
|
||||
|
|
Loading…
Reference in New Issue