mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[build] Commit generated init scripts (#11205)
This commit is contained in:
parent
7a52fed0d4
commit
e2dbf77a6c
7 changed files with 196 additions and 34 deletions
|
@ -307,12 +307,11 @@ npm run test:browser -- --dev # remove the --dev flag to run them once and close
|
|||
|
||||
### Building OS packages
|
||||
|
||||
Packages are built using fpm, pleaserun, dpkg, and rpm. fpm and pleaserun can be installed using gem. Package building has only been tested on Linux and is not supported on any other platform.
|
||||
Packages are built using fpm, dpkg, and rpm. Package building has only been tested on Linux and is not supported on any other platform.
|
||||
|
||||
```bash
|
||||
apt-get install ruby-dev rpm
|
||||
gem install fpm -v 1.5.0
|
||||
gem install pleaserun -v 0.0.24
|
||||
npm run build -- --skip-archives
|
||||
```
|
||||
|
||||
|
|
|
@ -24,10 +24,7 @@ module.exports = function (grunt) {
|
|||
'_build:versionedLinks',
|
||||
'_build:osShellScripts',
|
||||
grunt.option('skip-archives') ? [] : ['_build:archives'],
|
||||
grunt.option('skip-os-packages') ? [] : [
|
||||
'_build:pleaseRun',
|
||||
'_build:osPackages',
|
||||
],
|
||||
grunt.option('skip-os-packages') ? [] : ['_build:osPackages'],
|
||||
'_build:shasums'
|
||||
]));
|
||||
});
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
import exec from '../utils/exec';
|
||||
import { capitalize } from 'lodash';
|
||||
|
||||
export default (grunt) => {
|
||||
const { path, user, group, name } = grunt.config.get('packages');
|
||||
|
||||
grunt.registerTask('_build:pleaseRun', function () {
|
||||
grunt.config.get('services').forEach((service) => {
|
||||
grunt.file.mkdir(service.outputDir);
|
||||
exec('pleaserun', [
|
||||
'--install',
|
||||
'--no-install-actions',
|
||||
'--install-prefix', service.outputDir,
|
||||
'--overwrite',
|
||||
'--name', name,
|
||||
'--description', capitalize(name),
|
||||
'--user', user,
|
||||
'--group', group,
|
||||
'--sysv-log-path', `${path.logs}/`,
|
||||
'-p', service.name,
|
||||
'-v', service.version,
|
||||
path.kibanaBin,
|
||||
`-c ${path.kibanaConfig}`
|
||||
]);
|
||||
});
|
||||
});
|
||||
};
|
|
@ -0,0 +1,18 @@
|
|||
[Unit]
|
||||
Description=Kibana
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=kibana
|
||||
Group=kibana
|
||||
# Load env vars from /etc/default/ and /etc/sysconfig/ if they exist.
|
||||
# Prefixing the path with '-' makes it try to load, but if the file doesn't
|
||||
# exist, it continues onward.
|
||||
EnvironmentFile=-/etc/default/kibana
|
||||
EnvironmentFile=-/etc/sysconfig/kibana
|
||||
ExecStart=/usr/share/kibana/bin/kibana "-c /etc/kibana/kibana.yml"
|
||||
Restart=always
|
||||
WorkingDirectory=/
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
11
tasks/build/services/sysv/etc/default/kibana
Normal file
11
tasks/build/services/sysv/etc/default/kibana
Normal file
|
@ -0,0 +1,11 @@
|
|||
user="kibana"
|
||||
group="kibana"
|
||||
chroot="/"
|
||||
chdir="/"
|
||||
nice=""
|
||||
|
||||
|
||||
# If this is set to 1, then when `stop` is called, if the process has
|
||||
# not exited within a reasonable time, SIGKILL will be sent next.
|
||||
# The default behavior is to simply log a message "program stop failed; still running"
|
||||
KILL_ON_STOP_TIMEOUT=0
|
164
tasks/build/services/sysv/etc/init.d/kibana
Executable file
164
tasks/build/services/sysv/etc/init.d/kibana
Executable file
|
@ -0,0 +1,164 @@
|
|||
#!/bin/sh
|
||||
# Init script for kibana
|
||||
# Maintained by
|
||||
# Generated by pleaserun.
|
||||
# Implemented based on LSB Core 3.1:
|
||||
# * Sections: 20.2, 20.3
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: kibana
|
||||
# Required-Start: $remote_fs $syslog
|
||||
# Required-Stop: $remote_fs $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description:
|
||||
# Description: Kibana
|
||||
### END INIT INFO
|
||||
|
||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
||||
export PATH
|
||||
|
||||
name=kibana
|
||||
program=/usr/share/kibana/bin/kibana
|
||||
args=-c\\\ /etc/kibana/kibana.yml
|
||||
pidfile="/var/run/$name.pid"
|
||||
|
||||
[ -r /etc/default/$name ] && . /etc/default/$name
|
||||
[ -r /etc/sysconfig/$name ] && . /etc/sysconfig/$name
|
||||
|
||||
[ -z "$nice" ] && nice=0
|
||||
|
||||
trace() {
|
||||
logger -t "/etc/init.d/kibana" "$@"
|
||||
}
|
||||
|
||||
emit() {
|
||||
trace "$@"
|
||||
echo "$@"
|
||||
}
|
||||
|
||||
start() {
|
||||
|
||||
# Ensure the log directory is setup correctly.
|
||||
[ ! -d "/var/log/kibana/" ] && mkdir "/var/log/kibana/"
|
||||
chown "$user":"$group" "/var/log/kibana/"
|
||||
chmod 755 "/var/log/kibana/"
|
||||
|
||||
|
||||
# Setup any environmental stuff beforehand
|
||||
|
||||
|
||||
# Run the program!
|
||||
|
||||
chroot --userspec "$user":"$group" "$chroot" sh -c "
|
||||
|
||||
cd \"$chdir\"
|
||||
exec \"$program\" $args
|
||||
" >> /var/log/kibana/kibana.stdout 2>> /var/log/kibana/kibana.stderr &
|
||||
|
||||
# Generate the pidfile from here. If we instead made the forked process
|
||||
# generate it there will be a race condition between the pidfile writing
|
||||
# and a process possibly asking for status.
|
||||
echo $! > $pidfile
|
||||
|
||||
emit "$name started"
|
||||
return 0
|
||||
}
|
||||
|
||||
stop() {
|
||||
# Try a few times to kill TERM the program
|
||||
if status ; then
|
||||
pid=$(cat "$pidfile")
|
||||
trace "Killing $name (pid $pid) with SIGTERM"
|
||||
kill -TERM $pid
|
||||
# Wait for it to exit.
|
||||
for i in 1 2 3 4 5 ; do
|
||||
trace "Waiting $name (pid $pid) to die..."
|
||||
status || break
|
||||
sleep 1
|
||||
done
|
||||
if status ; then
|
||||
if [ "$KILL_ON_STOP_TIMEOUT" -eq 1 ] ; then
|
||||
trace "Timeout reached. Killing $name (pid $pid) with SIGKILL. This may result in data loss."
|
||||
kill -KILL $pid
|
||||
emit "$name killed with SIGKILL."
|
||||
else
|
||||
emit "$name stop failed; still running."
|
||||
fi
|
||||
else
|
||||
emit "$name stopped."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
status() {
|
||||
if [ -f "$pidfile" ] ; then
|
||||
pid=$(cat "$pidfile")
|
||||
if ps -p $pid > /dev/null 2> /dev/null ; then
|
||||
# process by this pid is running.
|
||||
# It may not be our pid, but that's what you get with just pidfiles.
|
||||
# TODO(sissel): Check if this process seems to be the same as the one we
|
||||
# expect. It'd be nice to use flock here, but flock uses fork, not exec,
|
||||
# so it makes it quite awkward to use in this case.
|
||||
return 0
|
||||
else
|
||||
return 2 # program is dead but pid file exists
|
||||
fi
|
||||
else
|
||||
return 3 # program is not running
|
||||
fi
|
||||
}
|
||||
|
||||
force_stop() {
|
||||
if status ; then
|
||||
stop
|
||||
status && kill -KILL $(cat "$pidfile")
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
force-start|start|stop|force-stop|restart)
|
||||
trace "Attempting '$1' on kibana"
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$1" in
|
||||
force-start)
|
||||
PRESTART=no
|
||||
exec "$0" start
|
||||
;;
|
||||
start)
|
||||
status
|
||||
code=$?
|
||||
if [ $code -eq 0 ]; then
|
||||
emit "$name is already running"
|
||||
exit $code
|
||||
else
|
||||
start
|
||||
exit $?
|
||||
fi
|
||||
;;
|
||||
stop) stop ;;
|
||||
force-stop) force_stop ;;
|
||||
status)
|
||||
status
|
||||
code=$?
|
||||
if [ $code -eq 0 ] ; then
|
||||
emit "$name is running"
|
||||
else
|
||||
emit "$name is not running"
|
||||
fi
|
||||
exit $code
|
||||
;;
|
||||
restart)
|
||||
|
||||
stop && start
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $SCRIPTNAME {start|force-start|stop|force-start|force-stop|status|restart}" >&2
|
||||
exit 3
|
||||
;;
|
||||
esac
|
||||
|
||||
exit $?
|
|
@ -9,6 +9,6 @@ module.exports = function (grunt) {
|
|||
['sysv', 'lsb-3.1']
|
||||
]
|
||||
.map(function ([ name, version ]) {
|
||||
return { name, version, outputDir: resolve(rootDir, `build/services/${name}`) };
|
||||
return { name, version, outputDir: resolve(rootDir, `tasks/build/services/${name}`) };
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue