marcaurele commented on a change in pull request #2226: CLOUDSTACK-10012: 
Towards CloudStack fat jar
URL: https://github.com/apache/cloudstack/pull/2226#discussion_r134218724
 
 

 ##########
 File path: packaging/centos63/cloud-management.rc
 ##########
 @@ -1,116 +1,153 @@
 #!/bin/bash
+
+### BEGIN INIT INFO
+# Provides:          cloudstack-management
+# Required-Start:    $network $local_fs
+# Required-Stop:     $network $local_fs
+# Default-Start:     3 4 5
+# Default-Stop:      0 1 2 6
+# Short-Description: Start/stop Apache CloudStack Usage Monitor
+# Description: This scripts Starts/Stops the Apache CloudStack Management 
Server
+### END INIT INFO
+
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
 # regarding copyright ownership.  The ASF licenses this file
 # to you under the Apache License, Version 2.0 (the
 # "License"); you may not use this file except in compliance
 # with the License.  You may obtain a copy of the License at
-# 
+#
 #   http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing,
 # software distributed under the License is distributed on an
 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-#
-# cloudstack-management      This shell script takes care of starting and 
stopping Tomcat
-#
-# chkconfig: - 80 20
-#
-### BEGIN INIT INFO
-# Provides: tomcat6
-# Required-Start: $network $syslog
-# Required-Stop: $network $syslog
-# Default-Start:
-# Default-Stop:
-# Description: Release implementation for Servlet 2.5 and JSP 2.1
-# Short-Description: start and stop tomcat
-### END INIT INFO
-#
-# - originally written by Henri Gomez, Keith Irwin, and Nicolas Mailhot
-# - heavily rewritten by Deepak Bhole and Jason Corley
-#
 
-if [ -r /etc/rc.d/init.d/functions ]; then
-    . /etc/rc.d/init.d/functions
-fi
-if [ -r /lib/lsb/init-functions ]; then
-    . /lib/lsb/init-functions
-fi
+. /etc/rc.d/init.d/functions
 
+SHORTNAME="cloudstack-management"
+PIDFILE=/var/run/"$SHORTNAME".pid
+LOCKFILE=/var/lock/subsys/"$SHORTNAME"
+LOGDIR=/var/log/cloudstack/management
+PROGNAME="CloudStack Management Server"
+CLASS="org.apache.cloudstack.ServerDaemon"
+PROG="jsvc"
+DAEMON="/usr/bin/jsvc"
+USER=cloud
 
-NAME="$(basename $(readlink -f $0))"
-export SERVICE_NAME="$NAME"
-stop() {
-       SHUTDOWN_WAIT="30"
-       count="0"
-       if [ -f /var/run/${NAME}.pid ]; then
-               pid=`cat /var/run/${NAME}.pid`
-               kill $pid &>/dev/null
-               until [ "$(ps --pid $pid | grep -c $pid)" -eq "0" ] || \
-                       [ "$count" -gt "$SHUTDOWN_WAIT" ]
-               do
-                       sleep 1
-                       let count="${count}+1"
-               done
-               if [ "$(ps --pid $pid | grep -c $pid)" -eq "0" ]; then
-                       log_success_msg "Stopping ${NAME}:"
-                       rm -f /var/run/${NAME}.pid
-                       rm -f /var/lock/subsys/${NAME}
-               else
-                       log_failure_msg "Stopping ${NAME}:"
-               fi
-       else
-               echo "Cannot find PID file of ${NAME}"
-               log_failure_msg "Stopping ${NAME}:"
-       fi
+export HOME="/var/cloudstack/management"
+
+unset OPTIONS
+[ -r /etc/sysconfig/default/"$SHORTNAME" ] && source 
/etc/sysconfig/default/"$SHORTNAME"
+
+setJavaHome() {
+  # use $JAVA_HOME if defined
+  if [ -n "$JAVA_HOME" ] ; then
+    return
+  fi
+
+  # try java first
+  java=$(which java 2>/dev/null || :)
+
+  # try javac if java is not found
+  if [ -z "$java" ] ; then
+    java=$(which javac 2>/dev/null || :)
+  fi
+
+  if [ -n "$java" ] ; then
+    JAVA_HOME=$(dirname $(dirname $(readlink -e $java)))
+    export JAVA_HOME
+    return
+  fi
+
+  # didnt find java home. exiting with error
+  exit 1
 }
 
-set_ulimit() {
-    fd_limit=`ulimit -n`
-    if [ "$fd_limit" != "4096" ]; then
-        user=`whoami`
-        if [ $user == "root" ]; then
-            ulimit -n 4096
+setJavaHome
+
+JARS=$(ls /usr/share/cloudstack-management/lib/*.jar | tr '\n' ':' | sed 
s'/.$//')
+CLASSPATH="/etc/cloudstack/management:/usr/share/cloudstack-common:/usr/share/cloudstack-management/setup:/usr/share/cloudstack-management:/usr/share/cloudstack-management/cloud-management-server.jar:$JARS"
 
 Review comment:
   `:$JARS` should be put in front here to first load extra JARs
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to