incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject svn commit: r1065619 - in /incubator/deltacloud/trunk/server: ./ lib/deltacloud/drivers/rimuhosting/ public/ support/fedora/
Date Mon, 31 Jan 2011 14:00:45 GMT
Author: mfojtik
Date: Mon Jan 31 14:00:44 2011
New Revision: 1065619

URL: http://svn.apache.org/viewvc?rev=1065619&view=rev
Log:
Updated RPM spec file, added init script for fedora.

Added:
    incubator/deltacloud/trunk/server/support/fedora/deltacloud-core   (with props)
Modified:
    incubator/deltacloud/trunk/server/deltacloud-core.gemspec
    incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb
    incubator/deltacloud/trunk/server/public/favicon.ico
    incubator/deltacloud/trunk/server/support/fedora/deltacloudd
    incubator/deltacloud/trunk/server/support/fedora/rubygem-deltacloud-core.spec

Modified: incubator/deltacloud/trunk/server/deltacloud-core.gemspec
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/deltacloud-core.gemspec?rev=1065619&r1=1065618&r2=1065619&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/deltacloud-core.gemspec (original)
+++ incubator/deltacloud/trunk/server/deltacloud-core.gemspec Mon Jan 31 14:00:44 2011
@@ -36,6 +36,7 @@ Gem::Specification.new do |s|
   s.summary = %q{Deltacloud REST API}
   s.files = FileList[
     'Rakefile',
+    '*.gemspec',
     'config.ru',
     '*.rb',
     'log',
@@ -43,6 +44,7 @@ Gem::Specification.new do |s|
     'support/fedora/**',
     'lib/**/*.rb',
     'lib/**/*.yml',
+    'tests/**/*.rb',
     'views/**/*.haml',
     'views/instance_states/*.erb',
     'public/favicon.ico',

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb?rev=1065619&r1=1065618&r2=1065619&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb
(original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb
Mon Jan 31 14:00:44 2011
@@ -1,4 +1,3 @@
-#
 # Copyright (C) 2009  RimuHosting Ltd
 # Author: Ivan Meredith <ivan@ivan.net.nz>
 #

Modified: incubator/deltacloud/trunk/server/public/favicon.ico
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/public/favicon.ico?rev=1065619&r1=1065618&r2=1065619&view=diff
==============================================================================
Files incubator/deltacloud/trunk/server/public/favicon.ico (original) and incubator/deltacloud/trunk/server/public/favicon.ico
Mon Jan 31 14:00:44 2011 differ

Added: incubator/deltacloud/trunk/server/support/fedora/deltacloud-core
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/support/fedora/deltacloud-core?rev=1065619&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/support/fedora/deltacloud-core (added)
+++ incubator/deltacloud/trunk/server/support/fedora/deltacloud-core Mon Jan 31 14:00:44 2011
@@ -0,0 +1,78 @@
+#!/bin/bash
+#
+#
+# deltacloud-core       startup script for deltacloud-core server
+#
+# chkconfig: - 97 03
+# description: deltacloud-core is primary server process for the \
+#    Deltacloud Core component.
+#
+
+[ -r /etc/sysconfig/deltacloud-core ] && . /etc/sysconfig/deltacloud-core
+
+ENV="${ENV:-production}"
+DRIVER="${DRIVER:-ec2}"
+PORT="${PORT:-3002}"
+LOCKFILE="${LOCKFILE:-/var/lock/subsys/deltacloud-core }"
+LOGFILE="${LOGFILE:-/var/log/deltacloud-core/$DRIVER.log}"
+
+[ ! -d /var/log/deltacloud-core ] && mkdir -p /var/log/deltacloud-core
+
+PROG=/usr/bin/deltacloudd
+
+. /etc/init.d/functions
+
+start() {
+    echo -n "Starting deltacloud-core: "
+
+    $PROG -i $DRIVER -e $ENV -p $PORT >> $LOGFILE 2>&1 &
+    RETVAL=$?
+    if [ $RETVAL -eq 0 ] && touch $LOCKFILE ; then
+      echo_success
+      echo
+    else
+      echo_failure
+      echo
+    fi
+}
+
+stop() {
+    echo -n "Shutting down deltacloud-core: "
+    RETVAL=$?
+    killall deltacloudd
+    if [ $RETVAL -eq 0 ] && rm -f $LOCKFILE ; then
+      echo_success
+      echo
+    else
+      echo_failure
+      echo
+    fi
+}
+
+case "$1" in
+    start)
+      start
+      ;;
+    stop)
+      stop
+      ;;
+    restart)
+      stop
+      start
+      ;;
+    reload)
+      ;;
+    force-reload)
+      restart
+      ;;
+    status)
+      status $PROG
+      RETVAL=$?
+      ;;
+    *)
+      echo "Usage: deltacloud-core {start|stop|restart|status}"
+      exit 1
+  ;;
+esac
+
+exit $RETVAL

Propchange: incubator/deltacloud/trunk/server/support/fedora/deltacloud-core
------------------------------------------------------------------------------
    svn:executable = *

Modified: incubator/deltacloud/trunk/server/support/fedora/deltacloudd
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/support/fedora/deltacloudd?rev=1065619&r1=1065618&r2=1065619&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/support/fedora/deltacloudd (original)
+++ incubator/deltacloud/trunk/server/support/fedora/deltacloudd Mon Jan 31 14:00:44 2011
@@ -2,10 +2,21 @@
 
 require 'rubygems'
 require 'optparse'
-require 'thin'
+
+# See if we can require +name+ and return +true+ if the library is there,
+# +false+ otherwise. Note that, as a side effect, the library will be
+# loaded
+def library_present?(name)
+  begin
+    require name
+    true
+  rescue LoadError
+    false
+  end
+end
 
 options = {
-  :env => 'production'
+  :env => 'development'
 }
 optparse = OptionParser.new do |opts|
 
@@ -25,6 +36,9 @@ BANNER
   opts.on( '-p', '--port PORT', 'Use PORT (default: 3001)') do |port|
     ENV["API_PORT"] = port
   end
+  opts.on( '-P', '--provider PROVIDER', 'Use PROVIDER (default is set in the driver)') do
|provider|
+    ENV['API_PROVIDER'] = provider
+  end
   opts.on( '-e', '--env ENV', 'Environment (default: "development")') { |env| options[:env]
= env }
   opts.on( '-h', '--help', '') { options[:help] = true }
 end
@@ -44,25 +58,71 @@ end
 ENV["API_HOST"] = "localhost" unless ENV["API_HOST"]
 ENV["API_PORT"] = "3001" unless ENV["API_PORT"]
 
-dirname="#{File.dirname(__FILE__)}/.."
+msg = "Starting Deltacloud API :: #{ENV["API_DRIVER"]} "
+msg << ":: #{ENV['API_PROVIDER']} " if ENV['API_PROVIDER']
+msg << ":: http://#{ENV["API_HOST"]}:#{ENV["API_PORT"]}/api"
+puts msg
+puts
 
-argv_opts = ARGV.clone
-argv_opts << ['start'] unless Thin::Runner.commands.include?(options[0])
-argv_opts << ['--address', ENV["API_HOST"] ]
-argv_opts << ['--port', ENV["API_PORT"] ]
-argv_opts << ['--rackup', 'config.ru' ]
-argv_opts << ['--chdir', dirname ]
-argv_opts << ['-e', options[:env] ]
-argv_opts << ['--threaded', '-D', '--stats', '/stats']
+dirname="#{File.dirname(__FILE__)}/.."
 
-argv_opts.flatten!
+have_thin = library_present?('thin')
+have_rerun = library_present?('rerun')
 
-puts "Starting Deltacloud API :: #{ENV["API_DRIVER"]} :: http://#{ENV["API_HOST"]}:#{ENV["API_PORT"]}/api"
-puts
+unless have_thin
+  require 'rack'
 
-thin = Thin::Runner.new(argv_opts)
-begin
-  thin.run!
-rescue Exception => e
-  puts "ERROR: #{e.message}"
+  # We can't chdir with webrick so add our root directory
+  # onto the load path
+  $: << dirname
+
+  # Read in config.ru and convert it to an instance of Rack::Builder
+  cfgfile = File.read(File.join(dirname, 'config.ru'))
+  inner_app = eval("Rack::Builder.new {(" + cfgfile + "\n )}.to_app",
+                   nil, 'config.ru')
+
+  app = Rack::Builder.new {
+    use Rack::CommonLogger # apache-like logging
+    use Rack::Reloader if options[:env] == "development"
+    set :root, dirname # Set Sinatra root since we can't chdir to ../
+    run inner_app
+  }.to_app
+
+  # There's a bug with string ports on JRuby so convert to int
+  # http://jira.codehaus.org/browse/JRUBY-4868
+  port = ENV["API_PORT"].to_i
+
+  puts "=> Ctrl-C to shutdown server"
+  Rack::Handler::WEBrick.run(app,
+                             :Host => ENV["API_HOST"],
+                             :Port => port,
+                             :AccessLog => [])
+else
+  argv_opts = ARGV.clone
+  argv_opts << ['start'] unless Thin::Runner.commands.include?(options[0])
+  argv_opts << ['--address', ENV["API_HOST"] ]
+  argv_opts << ['--port', ENV["API_PORT"] ]
+  argv_opts << ['--rackup', 'config.ru' ]
+  argv_opts << ['--chdir', dirname ]
+  argv_opts << ['-e', options[:env] ]
+  argv_opts << ['--threaded', '-D', '--stats', '/stats']
+
+  argv_opts.flatten!
+
+  if have_rerun && options[:env] == "development"
+    argv_opts.unshift "thin"
+    command = argv_opts.join(" ")
+    topdir = File::expand_path(File::join(File::dirname(__FILE__), ".."))
+    rerun = Rerun::Runner.new(command, :dir => topdir)
+    rerun.start
+    rerun.join
+  else
+    thin = Thin::Runner.new(argv_opts)
+
+    begin
+      thin.run!
+    rescue Exception => e
+      puts "ERROR: #{e.message}"
+    end
+  end
 end

Modified: incubator/deltacloud/trunk/server/support/fedora/rubygem-deltacloud-core.spec
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/support/fedora/rubygem-deltacloud-core.spec?rev=1065619&r1=1065618&r2=1065619&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/support/fedora/rubygem-deltacloud-core.spec (original)
+++ incubator/deltacloud/trunk/server/support/fedora/rubygem-deltacloud-core.spec Mon Jan
31 14:00:44 2011
@@ -5,29 +5,30 @@
 
 Summary: Deltacloud REST API
 Name: rubygem-%{gemname}
-Version: 0.0.1
-Release: 2%{?dist}
+Version: 0.2.0
+Release: 1%{?dist}
 Group: Development/Languages
 License: ASL 2.0 and MIT
-URL: http://www.deltacloud.org
+URL: http://incubator.apache.org/deltacloud
 Source0: http://gems.rubyforge.org/gems/%{gemname}-%{version}.gem
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 Requires: rubygems
 Requires: ruby(abi) = 1.8
-Requires: rubygem(eventmachine) >= 0.12.10
-Requires: rubygem(haml) >= 2.2.17
-Requires: rubygem(sinatra) >= 0.9.4
-Requires: rubygem(rack) >= 1.0.0
-Requires: rubygem(thin) >= 1.2.5
-Requires: rubygem(builder) >= 2.1.2
-Requires: rubygem(json) >= 1.2.3
-BuildRequires: ruby-json >= 1.1.9
-BuildRequires: rubygem(rake) >= 0.8.7
-BuildRequires: rubygem(rack-test) >= 0.4.0
-BuildRequires: rubygem(cucumber) >= 0.4.0
-BuildRequires: rubygem(rcov) >= 0.9.6
+Requires: rubygem(haml)
+Requires: rubygem(sinatra) >= 1.0
+Requires: rubygem(rack) >= 1.1.0
+Requires: rubygem(thin)
+Requires: rubygem(json) >= 1.4.0
+Requires(post): chkconfig
+Requires(preun): chkconfig
+Requires(preun): initscripts
+Requires(postun): initscripts
 BuildRequires: rubygems
 BuildRequires: ruby(abi) = 1.8
+BuildRequires: rubygem(json) >= 1.4.0
+BuildRequires: rubygem(rake) >= 0.8.7
+BuildRequires: rubygem(rack-test) >= 0.5.0
+BuildRequires: rubygem(rspec) >= 1.3.0
 BuildArch: noarch
 Provides: rubygem(%{gemname}) = %{version}
 
@@ -37,6 +38,14 @@ You do not directly link a Deltacloud li
 Instead, a client speaks the Deltacloud API over HTTP to a server
 which implements the REST interface.
 
+%package doc
+Summary: Documentation for %{name}
+Group: Documentation
+Requires:%{name} = %{version}-%{release}
+
+%description doc
+Documentation for %{name}
+
 %prep
 
 %build
@@ -44,48 +53,68 @@ which implements the REST interface.
 %install
 rm -rf %{buildroot}
 mkdir -p %{buildroot}%{gemdir}
+mkdir -p %{buildroot}%{_initddir}
 gem install --local --install-dir %{buildroot}%{gemdir} \
             --force --rdoc %{SOURCE0}
 mkdir -p %{buildroot}/%{_bindir}
-mv %{buildroot}%{geminstdir}/support/fedora/deltacloudd %{buildroot}/%{geminstdir}/bin
 mv %{buildroot}%{gemdir}/bin/* %{buildroot}/%{_bindir}
+mv %{buildroot}%{geminstdir}/support/fedora/%{gemname} %{buildroot}%{_initddir}
+mv -f %{buildroot}%{geminstdir}/support/fedora/deltacloudd %{buildroot}%{geminstdir}/bin
 rmdir %{buildroot}%{gemdir}/bin
-find %{buildroot}%{geminstdir}/bin -type f | xargs chmod a+x
-
-# Needs json_pure gem / not available in Fedora yet
-#%check
-#pushd %{buildroot}%{geminstdir}
-#cucumber features/*.feature
-#popd
+find %{buildroot}%{geminstdir}/bin -type f | xargs chmod 755
+find %{buildroot}%{geminstdir}/lib -type f | xargs chmod -x
+chmod 755 %{buildroot}%{_initddir}/%{gemname}
+
+%check
+pushd ./%{geminstdir}
+rake test
+popd
 
 %clean
 rm -rf %{buildroot}
 
+%post
+# This adds the proper /etc/rc*.d links for the script
+/sbin/chkconfig --add %{gemname}
+
+%preun
+if [ $1 -eq 0 ] ; then
+    /sbin/service %{gemname} stop >/dev/null 2>&1
+    /sbin/chkconfig --del %{gemname}
+fi
+
+%postun
+if [ "$1" -ge "1" ] ; then
+    /sbin/service %{gemname} condrestart >/dev/null 2>&1 || :
+fi
+
 %files
 %defattr(-, root, root, -)
+%{_initddir}/%{gemname}
 %{_bindir}/deltacloudd
-%{gemdir}/gems/%{gemname}-%{version}/bin
-%{gemdir}/gems/%{gemname}-%{version}/lib
-%{gemdir}/gems/%{gemname}-%{version}/public/favicon.ico
-%{gemdir}/gems/%{gemname}-%{version}/public/images
-%{gemdir}/gems/%{gemname}-%{version}/public/stylesheets
-%{gemdir}/gems/%{gemname}-%{version}/tests
-%{gemdir}/gems/%{gemname}-%{version}/views
-%{gemdir}/gems/%{gemname}-%{version}/Rakefile
-%{gemdir}/gems/%{gemname}-%{version}/*.rb
-%{gemdir}/gems/%{gemname}-%{version}/config.ru
-%doc %{gemdir}/gems/%{gemname}-%{version}/support/fedora
-%doc %{gemdir}/gems/%{gemname}-%{version}/COPYING
-%doc %{gemdir}/doc/%{gemname}-%{version}
+%dir %{geminstdir}/
+%{geminstdir}/bin
+%{geminstdir}/COPYING
+%{geminstdir}/config.ru
+%{geminstdir}/*.rb
+%{geminstdir}/Rakefile
+%{geminstdir}/views
+%{geminstdir}/lib
+%{geminstdir}/public/images
+%{geminstdir}/public/stylesheets
+%{geminstdir}/public/favicon.ico
 %{gemdir}/cache/%{gemname}-%{version}.gem
 %{gemdir}/specifications/%{gemname}-%{version}.gemspec
 # MIT
 %{gemdir}/gems/%{gemname}-%{version}/public/javascripts
 
+%files doc
+%defattr(-, root, root, -)
+%{gemdir}/doc/%{gemname}-%{version}
+%{geminstdir}/tests
+%{geminstdir}/support
+%{geminstdir}/%{gemname}.gemspec
+
 %changelog
-* Mon Apr 26 2010 Michal Fojtik <mfojtik@packager> - 0.0.1-1
+* Mon Jan 31 2011 Michal Fojtik <mfojtik@redhat.com> - 0.2.0-1
 - Initial package
-
-* Mon Apr 26 2010 Michal Fojtik <mfojtik@packager> - 0.0.1-2
-- Fixed broken dependencies
-- Added new launcher for Fedora



Mime
View raw message