You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2016/02/12 19:31:03 UTC

[17/19] ambari git commit: AMBARI-14842. ambari agent upstart support (aonishuk)

AMBARI-14842. ambari agent upstart support (aonishuk)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/fac9f36f
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/fac9f36f
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/fac9f36f

Branch: refs/heads/2.2.1-maint
Commit: fac9f36fc1e7822ee840bd35cc0820bd570a2af5
Parents: 116f016
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Fri Feb 12 11:44:32 2016 +0200
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Fri Feb 12 11:45:09 2016 +0200

----------------------------------------------------------------------
 ambari-agent/conf/unix/ambari-agent     | 13 +++++++++++
 ambari-agent/etc/init/ambari-agent.conf | 34 ++++++++++++++++++++++++++++
 ambari-agent/pom.xml                    | 22 ++++++++++++++++++
 3 files changed, 69 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/fac9f36f/ambari-agent/conf/unix/ambari-agent
----------------------------------------------------------------------
diff --git a/ambari-agent/conf/unix/ambari-agent b/ambari-agent/conf/unix/ambari-agent
index 50d13b1..27ade60 100755
--- a/ambari-agent/conf/unix/ambari-agent
+++ b/ambari-agent/conf/unix/ambari-agent
@@ -153,7 +153,14 @@ case "$1" in
         change_files_permissions
         
         echo "Starting ambari-agent"
+        
+        if [ "$AMBARI_AGENT_RUN_IN_FOREGROUND" == true ] ; then
+          $PYTHON $AMBARI_AGENT_PY_SCRIPT "$@" > $OUTFILE 2>&1 
+          exit $?
+        fi
+        
         nohup $PYTHON $AMBARI_AGENT_PY_SCRIPT "$@" > $OUTFILE 2>&1 &
+        
         sleep 2
         PID=$!
         echo "Verifying $AMBARI_AGENT process status..."
@@ -215,6 +222,12 @@ case "$1" in
             echo "Stopping $AMBARI_AGENT"
             change_files_permissions
             $PYTHON $AGENT_SCRIPT stop
+            
+            status ambari-agent 2>/dev/null | grep start 1>/dev/null
+            if [ "$?" -eq 0 ] ; then
+              echo "Stopping $AMBARI_AGENT upstart job"
+              stop ambari-agent > /dev/null
+            fi
           fi
           echo "Removing PID file at $PIDFILE"
           ambari-sudo.sh rm -f $PIDFILE

http://git-wip-us.apache.org/repos/asf/ambari/blob/fac9f36f/ambari-agent/etc/init/ambari-agent.conf
----------------------------------------------------------------------
diff --git a/ambari-agent/etc/init/ambari-agent.conf b/ambari-agent/etc/init/ambari-agent.conf
new file mode 100644
index 0000000..021eb3b
--- /dev/null
+++ b/ambari-agent/etc/init/ambari-agent.conf
@@ -0,0 +1,34 @@
+# 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
+
+#ambari-agent
+description     "ambari agent"
+
+stop on runlevel [06]
+
+env PIDFILE=/var/run/ambari-agent/ambari-agent.pid
+
+kill signal SIGKILL
+respawn
+
+script
+   . /etc/environment
+
+   export AMBARI_AGENT_RUN_IN_FOREGROUND=true
+   exec /etc/init.d/ambari-agent start
+end script
+
+post-stop script
+  rm -f $PIDFILE
+end script
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/fac9f36f/ambari-agent/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-agent/pom.xml b/ambari-agent/pom.xml
index b8f0407..63d6044 100644
--- a/ambari-agent/pom.xml
+++ b/ambari-agent/pom.xml
@@ -409,6 +409,17 @@
               <groupname>root</groupname>
             </mapping>
             <mapping>
+              <directory>/etc/init</directory>
+              <filemode>755</filemode>
+              <username>root</username>
+              <groupname>root</groupname>
+              <sources>
+                <source>
+                  <location>etc/init/ambari-agent.conf</location>
+                </source>
+              </sources>
+            </mapping>
+            <mapping>
               <directory>${init.d.dir}</directory>
               <filemode>755</filemode>
               <username>root</username>
@@ -620,6 +631,17 @@
               </mapper>
             </data>
             <data>
+              <src>etc/init/ambari-agent.conf</src>
+              <type>file</type>
+              <mapper>
+                <type>perm</type>
+                <prefix>/etc/init</prefix>
+                <user>root</user>
+                <group>root</group>
+                <filemode>755</filemode>
+              </mapper>
+            </data>
+            <data>
               <src>${basedir}/target/src/version</src>
               <type>file</type>
               <mapper>