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