changeset 27:76544ad0561d

switch kibana to ruby gem rather than jruby
author Carl Byington <carl@five-ten-sg.com>
date Mon, 06 May 2013 23:31:24 -0700
parents 610835fb4209
children 01ebc38d772e
files Kibana-no-git-patch Kibana.rc Kibana.spec Kibana.sysconfig Makefile
diffstat 5 files changed, 74 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Kibana-no-git-patch	Mon May 06 23:31:24 2013 -0700
@@ -0,0 +1,16 @@
+--- kibana.gemspec	2013-04-25 01:59:24.000000000 -0700
++++ kibana.new.gemspec	2013-05-06 23:04:47.780673300 -0700
+@@ -9,11 +9,11 @@
+   gem.homepage = "http://rashidkpc.github.com/Kibana/"
+   gem.license = "MIT License"
+ 
+-  gem.files = `git ls-files`.split("\n")
++  gem.files = `find * -type f`.split("\n")
+   gem.name = "kibana"
+   gem.require_paths = ["lib"]
+   gem.version = Kibana::VERSION
+-  gem.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
++  gem.executables   = `find bin/* -type f`.split("\n").map{ |f| File.basename(f) }
+ 
+   gem.add_runtime_dependency 'sinatra'
+   gem.add_runtime_dependency 'json'
--- a/Kibana.rc	Fri May 03 08:04:08 2013 -0700
+++ b/Kibana.rc	Mon May 06 23:31:24 2013 -0700
@@ -22,12 +22,6 @@
 . /etc/sysconfig/Kibana
 
 DESC="Kibana Daemon"
-JAVA=$(which java 2>/dev/null)
-if [ "$(which jruby 2>/dev/null)" == '' ]; then
-    JRUBY_CMD="$JAVA $JAVAARGS -jar /usr/share/jruby.jar"
-else
-    JRUBY_CMD="jruby"
-fi
 LOGFILE=/var/log/Kibana/Kibana.log
 PIDFILE=/var/run/Kibana.pid
 base=Kibana
@@ -38,17 +32,14 @@
 # Function that starts the daemon/service
 #
 do_start() {
-    cd /usr/share/java/Kibana
+    cd /home/kibana
     pid=$(
     exec sudo -u kibana /bin/bash - <<EOF
-        export GEM_HOME=$(pwd)
-        export GEM_PATH=
-        export JAVA_MEM=$JAVA_MEM
-        export JAVA_STACK=$JAVA_STACK
         export KIBANA_HOST=$KIBANA_HOST
         export KIBANA_PORT=$KIBANA_PORT
         export KIBANA_ES=$KIBANA_ES
-        $JRUBY_CMD kibana.rb >>$LOGFILE 2>&1 &
+        export KIBANA_CONFIG=$KIBANA_CONFIG
+        kibana >>$LOGFILE 2>&1 &
         echo \$!
 EOF
     )
--- a/Kibana.spec	Fri May 03 08:04:08 2013 -0700
+++ b/Kibana.spec	Mon May 06 23:31:24 2013 -0700
@@ -3,11 +3,14 @@
 
 %global commit df8ae2344433e5072a8dfe77082acfd1c9b6ed62
 %global shortcommit %(c=%{commit}; echo ${c:0:8})
-%global name2 kibana
+%global name2    kibana
+%global gem_dir  %(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null)
+%global gem_name kibana
+%global gem_instdir %{gem_dir}/gems/%{gem_name}-%{version}
 
 Name:           Kibana
 Version:        0.2.0
-Release:        0%{?dist}
+Release:        1%{?dist}
 Summary:        Kibana is a user friendly way to view, search and visualize your log data
 
 Group:          System Environment/Daemons
@@ -16,14 +19,26 @@
 BuildArch:      noarch
 Source0:        https://nodeload.github.com/rashidkpc/Kibana/archive/%{commit}/%{name}-%{version}-%{shortcommit}.tar.gz
 Source1:        Kibana-external-config-patch
+Source2:        Kibana-no-git-patch
 Source10:       %{name}.rc
 Source13:       %{name}.sysconfig
 BuildRoot:      %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
 Autoreq:        0
 
-BuildRequires:  jruby java-devel
+BuildRequires: ruby
+BuildRequires: ruby-devel
+BuildRequires: rubygems
+Provides: rubygem(%{gem_name}) = %{version}
 
-Requires:       jruby java-devel elasticsearch logstash
+Requires: ruby
+Requires: rubygems
+Requires: rubygem(sinatra)
+Requires: rubygem(json)
+Requires: rubygem(fastercsv)
+Requires: rubygem(daemons)
+Requires: rubygem(tzinfo)
+Requires: rubygem(thin)
+Requires: elasticsearch logstash
 Requires(pre):          /usr/sbin/useradd
 Requires(pre):          /usr/bin/getent
 Requires(postun):       /usr/sbin/userdel
@@ -39,35 +54,29 @@
 %prep
 %setup -qn %{name}-%{commit}
 patch <%SOURCE1
+patch <%SOURCE2
 
 
 %build
-if [ "$(which jruby)" == '' ]; then
-    JRUBY_CMD="java -jar /usr/share/jruby.jar"
-else
-    JRUBY_CMD="jruby"
-fi
-export GEM_HOME=$(pwd)
-export GEM_PATH=
-$JRUBY_CMD -S gem install bundler
-$JRUBY_CMD bin/bundle install
-rm -rf gems/*/test
-rm -rf gems/*/spec
-rm -rf gems/*/examples
-rm -rf sample spec
+mkdir -p ./%{gem_dir}
+gem build %{gem_name}.gemspec
+gem install --local --install-dir ./%{gem_dir} -V --force --no-rdoc --no-ri %{gem_name}-%{version}.gem
 
 
 %install
-rm -rf                          $RPM_BUILD_ROOT
-install -d                      $RPM_BUILD_ROOT/var/log/%{name}
-install -d                      $RPM_BUILD_ROOT/%{_javadir}/%{name}
-cp -a *                         $RPM_BUILD_ROOT/%{_javadir}/%{name}
-install -D -m 755 %SOURCE10     $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}
-install -D -m 640 %SOURCE13     $RPM_BUILD_ROOT/etc/sysconfig/%{name}
+rm -rf                                  $RPM_BUILD_ROOT
+mkdir -p                                $RPM_BUILD_ROOT/%{gem_dir}
+mkdir -p                                $RPM_BUILD_ROOT/%{_prefix}
+cp -pa ./%{gem_dir}/*                   $RPM_BUILD_ROOT/%{gem_dir}
+mv -f $RPM_BUILD_ROOT/%{gem_dir}/bin    $RPM_BUILD_ROOT/%{_prefix}
+install -d                              $RPM_BUILD_ROOT/var/log/%{name}
+install -D -m 755 %SOURCE10             $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}
+install -D -m 640 %SOURCE13             $RPM_BUILD_ROOT/etc/sysconfig/%{name}
+mv -f %{name}Config.rb                  $RPM_BUILD_ROOT/etc/sysconfig/%{name}Config.rb
 
 
 %pre
-/usr/bin/getent passwd %{name2} >/dev/null || /usr/sbin/useradd -r -c "%{name} pseudo-user" %{name2} >/dev/null
+/usr/bin/getent passwd %{name2} >/dev/null || /usr/sbin/useradd -r -m -c "%{name} pseudo-user" %{name2} >/dev/null
 
 
 %post
@@ -88,15 +97,21 @@
 
 
 %files
-%defattr(-,root,root,-)
-%attr(0750,%{name2},root) %{_javadir}/*
+%defattr(-, root, root, -)
+%{_bindir}/%{gem_name}
+%{gem_dir}/cache/%{gem_name}-%{version}.gem
+%{gem_dir}/specifications/%{gem_name}-%{version}.gemspec
+%{gem_instdir}
 %config(noreplace) %attr(0640,%{name2},root) /etc/sysconfig/%{name}
+%config(noreplace) %attr(0640,%{name2},root) /etc/sysconfig/%{name}Config.rb
 %dir %attr(0750,%{name2},root) /var/log/%{name}
 /etc/rc.d/init.d/%{name}
 
 
+%changelog
+* Mon May 06 2013  <carl@five-ten-sg.com> - 0.2.0-1
+- switch to building standard ruby gem, avoid jruby
 
-%changelog
 * Fri Apr 25 2013  <carl@five-ten-sg.com> - 0.2.0-0
 - Initial build.
 
--- a/Kibana.sysconfig	Fri May 03 08:04:08 2013 -0700
+++ b/Kibana.sysconfig	Mon May 06 23:31:24 2013 -0700
@@ -1,13 +1,5 @@
 # used by /etc/rc.d/init.d/Kibana
 
-# extra args for jruby
-JAVA_MEM="-Xmx500m"
-JAVA_STACK=
-
-# extra args for java
-#JAVAARGS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000 -verbose"
-JAVAARGS="$JAVA_MEM $JAVA_STACK"
-
 # kibana listening on all interfaces
 KIBANA_HOST=0.0.0.0
 
@@ -16,3 +8,7 @@
 
 # kibana connection to elasticsearch
 KIBANA_ES="localhost:9200"
+
+# kibana main config
+KIBANA_CONFIG=/etc/sysconfig/KibanaConfig.rb
+
--- a/Makefile	Fri May 03 08:04:08 2013 -0700
+++ b/Makefile	Mon May 06 23:31:24 2013 -0700
@@ -36,20 +36,20 @@
 	done
 	# build the source rpms
 	rpmbuild --define "dist $(dist)" --define "_sourcedir $(shell pwd)" --define "_srcrpmdir $(shell pwd)" --define "_rpmdir $(shell pwd)" -bs Kibana.spec
-	rpmbuild --define "dist $(dist)" --define "_sourcedir $(shell pwd)" --define "_srcrpmdir $(shell pwd)" --define "_rpmdir $(shell pwd)" -bs jruby.spec
-	rpmbuild --define "dist $(dist)" --define "_sourcedir $(shell pwd)" --define "_srcrpmdir $(shell pwd)" --define "_rpmdir $(shell pwd)" -bs GraphTastic-client.spec
-	rpmbuild --define "dist $(dist)" --define "_sourcedir $(shell pwd)" --define "_srcrpmdir $(shell pwd)" --define "_rpmdir $(shell pwd)" -bs elasticsearch.spec
-	rpmbuild --define "dist $(dist)" --define "_sourcedir $(shell pwd)" --define "_srcrpmdir $(shell pwd)" --define "_rpmdir $(shell pwd)" -bs logstash.spec
+	#rpmbuild --define "dist $(dist)" --define "_sourcedir $(shell pwd)" --define "_srcrpmdir $(shell pwd)" --define "_rpmdir $(shell pwd)" -bs jruby.spec
+	#rpmbuild --define "dist $(dist)" --define "_sourcedir $(shell pwd)" --define "_srcrpmdir $(shell pwd)" --define "_rpmdir $(shell pwd)" -bs GraphTastic-client.spec
+	#rpmbuild --define "dist $(dist)" --define "_sourcedir $(shell pwd)" --define "_srcrpmdir $(shell pwd)" --define "_rpmdir $(shell pwd)" -bs elasticsearch.spec
+	#rpmbuild --define "dist $(dist)" --define "_sourcedir $(shell pwd)" --define "_srcrpmdir $(shell pwd)" --define "_rpmdir $(shell pwd)" -bs logstash.spec
 
 rpm:
 	# kill off maven repository cache
 	rm -rf ~/.m2
 	# build binary rpms
-	rpmbuild --define "dist $(dist)" --define "_rpmdir $(shell pwd)" --rebuild Kibana-$(lv)-0$(dist).src.rpm
-	rpmbuild --define "dist $(dist)" --define "_rpmdir $(shell pwd)" --rebuild jruby-$(jv)-0$(dist).src.rpm
-	rpmbuild --define "dist $(dist)" --define "_rpmdir $(shell pwd)" --rebuild GraphTastic-client-0.0.0-0$(dist).src.rpm
-	rpmbuild --define "dist $(dist)" --define "_rpmdir $(shell pwd)" --rebuild elasticsearch-$(hv)-0$(dist).src.rpm
-	rpmbuild --define "dist $(dist)" --define "_rpmdir $(shell pwd)" --rebuild logstash-$(gv)-0$(dist).src.rpm
+	rpmbuild --define "dist $(dist)" --define "_rpmdir $(shell pwd)" --rebuild Kibana-$(lv)-1$(dist).src.rpm
+	#rpmbuild --define "dist $(dist)" --define "_rpmdir $(shell pwd)" --rebuild jruby-$(jv)-0$(dist).src.rpm
+	#rpmbuild --define "dist $(dist)" --define "_rpmdir $(shell pwd)" --rebuild GraphTastic-client-0.0.0-0$(dist).src.rpm
+	#rpmbuild --define "dist $(dist)" --define "_rpmdir $(shell pwd)" --rebuild elasticsearch-$(hv)-0$(dist).src.rpm
+	#rpmbuild --define "dist $(dist)" --define "_rpmdir $(shell pwd)" --rebuild logstash-$(gv)-0$(dist).src.rpm
 
 package-web:
 	tar cfz logstash.fedora.tar.gz *.src.rpm $$(hg status -c | cut -c3-)