Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build] Commit generated init scripts #11205

Merged
merged 1 commit into from
Sep 28, 2017
Merged

Conversation

jbudz
Copy link
Member

@jbudz jbudz commented Apr 12, 2017

  1. We don't have any version locking on dependent ruby gems other than docs. This could cause accidental inconsistencies.
  2. We can make modifications, giving us more freedom to investigate issues like Setting NODE_OPTIONS with Debian/Ubuntu packages #7237, [Packaging] systemd Service Unit Should Create a PID directory #7759, Documentation for configuring --max-old-space-size #9006, systemd restart loop, reported as running with no errors #10895, etc

@jbudz jbudz added review v6.0.0 Team:Operations Team label for Operations Team labels Apr 12, 2017
@jbudz
Copy link
Member Author

jbudz commented Apr 21, 2017

I'm closing this one for now, but may come back to it. pleaserun 0.0.28 will help us set environment variables addressing a few of the issues in number 2. Number one can be solved with a gemfile.

@jbudz jbudz closed this Apr 21, 2017
@jbudz jbudz reopened this Aug 25, 2017
@jbudz jbudz added v7.0.0 and removed v6.0.0 labels Aug 25, 2017
@jbudz
Copy link
Member Author

jbudz commented Aug 25, 2017

I got back to this and did some digging, reopening for a few reasons.

  1. we need to export NODE_OPTIONS in the sysv scripts to make it available to the bin/kibana script
  2. pleaserun's sysv service manages /var/run/kibana. We want to modify this to create a folder, and use kibana.yml to use that folder
  3. sysv also pipes logs from stdout to /var/log/kibana.log. We want kibana.yml to manage this too.
  4. systemd will retry starting infinity times. permissions issues are fairly common, and this can cause a ton of alerts to get fired on monitoring services

This PR doesn't address any of those issues - I'm keeping this separate so we don't lose it on a merge and for future reference.

@tylersmalley
Copy link
Contributor

We were previously using pleaserun to output kibana.plist and kibana.conf. Should those also be included?

Would it be worth it to keep a task around which uses pleaserun to update these files?

@jbudz
Copy link
Member Author

jbudz commented Sep 20, 2017

We aren't making use of kibana.conf and .plist so we should be able to remove them.

For the pleaserun task I'd opt for removing it and pull in updates manually if needed, the more we diverge the more off it will be. As an in between how about a followup PR (or commit here and merge without squashing) to bump this to latest before we start adding changes?

@tylersmalley
Copy link
Contributor

You're right, if we intend on diverging from the pleaserun output then there isn't much of a point to including the tasks.

I bumped pleaserun to 0.0.30 and the only changes were to the init script.

diff --git a/tasks/build/services/sysv/etc/init.d/kibana b/tasks/build/services/sysv/etc/init.d/kibana
index 94066b0c07..07cc25a899 100755
--- a/tasks/build/services/sysv/etc/init.d/kibana
+++ b/tasks/build/services/sysv/etc/init.d/kibana
@@ -20,11 +20,26 @@ export PATH

 name=kibana
 program=/usr/share/kibana/bin/kibana
-args=-c\\\ /etc/kibana/kibana.yml
+args=-c\ /etc/kibana/kibana.yml
 pidfile="/var/run/$name.pid"
+user="kibana"
+group="kibana"
+chroot="/"
+chdir="/"
+nice=""

-[ -r /etc/default/$name ] && . /etc/default/$name
-[ -r /etc/sysconfig/$name ] && . /etc/sysconfig/$name
+
+# 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
+
+# When loading default and sysconfig files, we use `set -a` to make
+# all variables automatically into environment variables.
+set -a
+[ -r /etc/default/kibana ] && . /etc/default/kibana
+[ -r /etc/sysconfig/kibana ] && . /etc/sysconfig/kibana
+set +a

 [ -z "$nice" ] && nice=0

@@ -40,9 +55,11 @@ emit() {
 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/"
+  if [ ! -d "/var/log/kibana/" ]; then
+    mkdir "/var/log/kibana/"
+    chown "$user":"$group" "/var/log/kibana/"
+    chmod 755 "/var/log/kibana/"
+  fi


   # Setup any environmental stuff beforehand
@@ -54,7 +71,7 @@ start() {

     cd \"$chdir\"
     exec \"$program\" $args
-  " >> /var/log/kibana/kibana.stdout 2>> /var/log/kibana/kibana.stderr &
+  " >> /var/log/kibana/kibana-stdout.log 2>> /var/log/kibana/kibana-stderr.log &

   # Generate the pidfile from here. If we instead made the forked process
   # generate it there will be a race condition between the pidfile writing

We might as well take advantage of the updates.

Here are the commands I used:

pleaserun --install --no-install-actions --install-prefix tasks/build/services/systemd --overwrite --name kibana --description Kibana --user kibana --group kibana --log-directory /var/log/kibana/ -p systemd -v default /usr/share/kibana/bin/kibana -c /etc/kibana/kibana.yml

pleaserun --install --no-install-actions --install-prefix tasks/build/services/sysv --overwrite --name kibana --description Kibana --user kibana --group kibana --log-directory /var/log/kibana/ -p sysv -v lsb-3.1 /usr/share/kibana/bin/kibana -c /etc/kibana/kibana.yml

Copy link
Contributor

@tylersmalley tylersmalley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - let's move forward with the version of pleaserun we are on and we can bump in a subsequent PR

@jbudz jbudz merged commit e2dbf77 into elastic:master Sep 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review Team:Operations Team label for Operations Team v7.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants