mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[server/pid] move pid to it's own config, allow setting exclusive=true
This commit is contained in:
parent
8d7ae77f56
commit
4f5f523946
4 changed files with 19 additions and 7 deletions
|
@ -57,7 +57,7 @@
|
|||
# server.ssl.key: /path/to/your/server.crt
|
||||
|
||||
# Set the path to where you would like the process id file to be created.
|
||||
# server.pidFile: /var/run/kibana.pid
|
||||
# pid.file: /var/run/kibana.pid
|
||||
|
||||
# If you would like to send the log output to a file you can set the path below.
|
||||
# logging.dest: stdout
|
||||
|
|
|
@ -7,7 +7,7 @@ var legacySettingMap = {
|
|||
// server
|
||||
port: 'server.port',
|
||||
host: 'server.host',
|
||||
pid_file: 'server.pidFile',
|
||||
pid_file: 'pid.file',
|
||||
ssl_cert_file: 'server.ssl.cert',
|
||||
ssl_key_file: 'server.ssl.key',
|
||||
|
||||
|
|
|
@ -11,11 +11,15 @@ module.exports = Joi.object({
|
|||
prod: Joi.boolean().default(Joi.ref('$prod'))
|
||||
}).default(),
|
||||
|
||||
pid: Joi.object({
|
||||
file: Joi.string(),
|
||||
exclusive: Joi.boolean().default(false)
|
||||
}).default(),
|
||||
|
||||
server: Joi.object({
|
||||
host: Joi.string().hostname().default('0.0.0.0'),
|
||||
port: Joi.number().default(5601),
|
||||
defaultRoute: Joi.string(),
|
||||
pidFile: Joi.string(),
|
||||
ssl: Joi.object({
|
||||
cert: Joi.string(),
|
||||
key: Joi.string()
|
||||
|
|
|
@ -4,19 +4,27 @@ var writeFile = Promise.promisify(require('fs').writeFile);
|
|||
var unlink = require('fs').unlinkSync;
|
||||
|
||||
module.exports = Promise.method(function (kbnServer, server, config) {
|
||||
var path = config.get('server.pidFile');
|
||||
var pid = String(process.pid);
|
||||
var path = config.get('pid.file');
|
||||
if (!path) return;
|
||||
|
||||
var pid = String(process.pid);
|
||||
|
||||
return writeFile(path, pid, { flag: 'wx' })
|
||||
.catch(function (err) {
|
||||
if (err.code !== 'EEXIST') throw err;
|
||||
|
||||
server.log(['pid', 'warning'], {
|
||||
var log = {
|
||||
tmpl: 'pid file already exists at <%= path %>',
|
||||
path: path,
|
||||
pid: pid
|
||||
});
|
||||
};
|
||||
|
||||
if (config.get('pid.exclusive')) {
|
||||
server.log(['pid', 'fatal'], log);
|
||||
process.exit(1);
|
||||
} else {
|
||||
server.log(['pid', 'warning'], log);
|
||||
}
|
||||
|
||||
return writeFile(path, pid);
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue