deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mohammed Morsi <mmo...@redhat.com>
Subject [PATCH] daemonize deltacloudd for appliance, added deltacloudd init script
Date Thu, 23 Sep 2010 18:42:40 GMT
---
 server/bin/deltacloudd                 |    8 ++-
 server/support/fedora/deltacloudd.init |   74 ++++++++++++++++++++++++++++++++
 2 files changed, 79 insertions(+), 3 deletions(-)
 create mode 100755 server/support/fedora/deltacloudd.init

diff --git a/server/bin/deltacloudd b/server/bin/deltacloudd
index 9d91e1a..d176311 100755
--- a/server/bin/deltacloudd
+++ b/server/bin/deltacloudd
@@ -89,8 +89,6 @@ else
   argv_opts << ['-e', options[:env] ]
   argv_opts << ['--threaded', '-D', '--stats', '/stats']
 
-  argv_opts.flatten!
-
   if options[:env] == "development"
     use_rerun = false
     begin
@@ -99,8 +97,12 @@ else
     rescue
       # Do nothing
     end
+  else
+    argv_opts << ['-d']
   end
 
+  argv_opts.flatten!
+
   if use_rerun
     argv_opts.unshift "thin"
     command = argv_opts.join(" ")
@@ -114,7 +116,7 @@ else
     begin
       thin.run!
     rescue Exception => e
-      puts "ERROR: #{e.message}"
+      puts "ERROR: #{e.message}" unless e.class == SystemExit
     end
   end
 end
diff --git a/server/support/fedora/deltacloudd.init b/server/support/fedora/deltacloudd.init
new file mode 100755
index 0000000..b6a1b89
--- /dev/null
+++ b/server/support/fedora/deltacloudd.init
@@ -0,0 +1,74 @@
+#!/bin/bash
+#
+#
+# deltacloudd       startup script for deltacloudd server
+#
+# chkconfig: - 97 03
+# description: deltacloudd is primary server process for the \
+#    Deltacloud API component.
+#
+
+[ -r /etc/sysconfig/deltacloudd ] && . /etc/sysconfig/deltacloudd
+
+ENV="${ENV:-production}"
+DRIVER="${DRIVER:-ec2}"
+LOCKFILE="${LOCKFILE:-/var/lock/subsys/deltacloudd }"
+
+PROG=/usr/bin/deltacloudd
+
+. /etc/init.d/functions
+
+start() {
+    echo -n "Starting deltacloudd: "
+
+    $PROG -i $DRIVER -e $ENV&
+    RETVAL=$?
+    if [ $RETVAL -eq 0 ] && touch $LOCKFILE ; then
+      echo_success
+      echo
+    else
+      echo_failure
+      echo
+    fi
+}
+
+stop() {
+    echo -n "Shutting down deltacloudd: "
+    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: deltacloudd {start|stop|restart|status}"
+      exit 1
+  ;;
+esac
+
+exit $RETVAL
-- 
1.7.2.1


Mime
View raw message