AMBARI-14643. Ambari agent dir is not recreated if /var/run/<ambari_dir> is 
deleted on non-root agent (aonishuk)


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

Branch: refs/heads/branch-2.2
Commit: d12ac74ded2349960ae4a09c1b99f826434e1a92
Parents: 5d96e18
Author: Andrew Onishuk <aonis...@hortonworks.com>
Authored: Wed Jan 13 09:19:19 2016 +0200
Committer: Andrew Onishuk <aonis...@hortonworks.com>
Committed: Wed Jan 13 09:19:19 2016 +0200

----------------------------------------------------------------------
 ambari-agent/conf/unix/ambari-agent               | 6 ++++--
 ambari-agent/src/main/python/ambari_agent/main.py | 6 ------
 2 files changed, 4 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d12ac74d/ambari-agent/conf/unix/ambari-agent
----------------------------------------------------------------------
diff --git a/ambari-agent/conf/unix/ambari-agent 
b/ambari-agent/conf/unix/ambari-agent
index c54af21..50d13b1 100755
--- a/ambari-agent/conf/unix/ambari-agent
+++ b/ambari-agent/conf/unix/ambari-agent
@@ -41,7 +41,8 @@ export PYTHONPATH=/usr/lib/python2.6/site-packages:$PYTHONPATH
 
 AMBARI_AGENT=ambari-agent
 PYTHON_WRAP=/var/lib/ambari-agent/ambari-python-wrap
-PIDFILE=/var/run/ambari-agent/$AMBARI_AGENT.pid
+PIDDIR=/var/run/ambari-agent
+PIDFILE=$PIDDIR/$AMBARI_AGENT.pid
 OUTFILE=/var/log/ambari-agent/ambari-agent.out
 LOGFILE=/var/log/ambari-agent/ambari-agent.log
 AGENT_SCRIPT=/usr/lib/python2.6/site-packages/ambari_agent/main.py
@@ -72,7 +73,8 @@ change_files_permissions() {
     if [ ! -z "$keysdir" ]; then
         ambari-sudo.sh chown -R $current_user "$keysdir"
     fi
-       ambari-sudo.sh chown -R $current_user "/var/run/ambari-agent/"
+       ambari-sudo.sh mkdir -p "$PIDDIR"
+       ambari-sudo.sh chown -R $current_user "$PIDDIR"
        ambari-sudo.sh chown -R $current_user "/var/log/ambari-agent/"
        ambari-sudo.sh chown -R $current_user "/var/lib/ambari-agent/data/"
        ambari-sudo.sh chown -R $current_user "/var/lib/ambari-agent/cache/"

http://git-wip-us.apache.org/repos/asf/ambari/blob/d12ac74d/ambari-agent/src/main/python/ambari_agent/main.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/main.py 
b/ambari-agent/src/main/python/ambari_agent/main.py
index 307424e..22e2e4a 100644
--- a/ambari-agent/src/main/python/ambari_agent/main.py
+++ b/ambari-agent/src/main/python/ambari_agent/main.py
@@ -161,12 +161,6 @@ def perform_prestart_checks(expected_hostname):
 
 
 def daemonize():
-  # Daemonize current instance of Ambari Agent
-  # Currently daemonization is done via /usr/sbin/ambari-agent script (nohup)
-  # and agent only dumps self pid to file
-  if not os.path.exists(ProcessHelper.piddir):
-    os.makedirs(ProcessHelper.piddir, 0755)
-
   pid = str(os.getpid())
   file(ProcessHelper.pidfile, 'w').write(pid)
 

Reply via email to