You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ambari.apache.org by Mauro Cortellazzi <ma...@radicalbit.io> on 2016/02/01 11:06:07 UTC

Check status for custom service doesn't work

Hi All,
I'm using Ambari 2.1.2 with HDP 2.3 and I have created a custom service 
following this guide:
http://mozartanalytics.com/how-to-create-a-software-stack-for-ambari/
Once the service is installed I'm able to start it and stop it with 
Ambari, but the check status method always said me that service is not 
running (but it's running).
The status function is similar to the code below (I have only change the 
path of the pid file):

def status(self, env):
   pid_file ="/var/run/my-service.pid"
   check_process_status(pid_file)

I've checked the file and its content: it is created in the right and it 
contains the correct pid.
I've checked the check_process_status code and I have seen that it does 
a "kill -0 <PID>", so I tried the same command in the shell and it works 
properly.
The python version used is 2.7.

Does anyone have a suggestion?
Many thanks for your help and your time!!
Bests.

Mauro

Re: Check status for custom service doesn't work

Posted by Mauro Cortellazzi <ma...@radicalbit.io>.
Hi Alejandro, thanks for your reply.
Ambari agent is runned as root user.
I have checked the file /etc/ambari-agent/conf/ambari-agent.ini and also 
into config file is setted run_as_user=root.
I have also checked with the following two commands:

[root@c7201 ~]# cat /var/run/ambari-agent/ambari-agent.pid

2343

[root@c7201 ~]# ps -ef | grep ambari_agent

root      2082     1  0 08:14 ?        00:00:00 /usr/bin/python2.7 /usr/lib/python2.6/site-packages/ambari_agent/AmbariAgent.py start

root      2343  2082  0 08:14 ?        00:00:00 /usr/bin/python2.7 /usr/lib/python2.6/site-packages/ambari_agent/main.py start


So I think I could said that agent is running correctly with root user 
and its permissions.

Then I started my service and checked its pid file: it is correctly 
created and with the correct pid (in this case 3743).
So I typed the following commands:

[root@c7201 ~]# kill -0 3743

[root@c7201 ~]# echo $?

0


Do you think I'm doing something wrong? Any suggestions?
Thank you again for your support and your time!!
Bests
Mauro


On 01/02/2016 20:26, Alejandro Fernandez wrote:
> Does the user running ambari agent have permission to cat the pid file 
> and check if that process is up?
>
> Thanks,
> Alejandro
>
> From: Mauro Cortellazzi <mauro.cortellazzi@radicalbit.io 
> <ma...@radicalbit.io>>
> Reply-To: "user@ambari.apache.org <ma...@ambari.apache.org>" 
> <user@ambari.apache.org <ma...@ambari.apache.org>>
> Date: Monday, February 1, 2016 at 2:06 AM
> To: "user@ambari.apache.org <ma...@ambari.apache.org>" 
> <user@ambari.apache.org <ma...@ambari.apache.org>>
> Subject: Check status for custom service doesn't work
>
> Hi All,
> I'm using Ambari 2.1.2 with HDP 2.3 and I have created a custom 
> service following this guide:
> http://mozartanalytics.com/how-to-create-a-software-stack-for-ambari/
> Once the service is installed I'm able to start it and stop it with 
> Ambari, but the check status method always said me that service is not 
> running (but it's running).
> The status function is similar to the code below (I have only change 
> the path of the pid file):
> def status(self, env):
>    pid_file ="/var/run/my-service.pid"
>    check_process_status(pid_file)
> I've checked the file and its content: it is created in the right and 
> it contains the correct pid.
> I've checked the check_process_status code and I have seen that it 
> does a "kill -0 <PID>", so I tried the same command in the shell and 
> it works properly.
> The python version used is 2.7.
>
> Does anyone have a suggestion?
> Many thanks for your help and your time!!
> Bests.
>
> Mauro


Re: Check status for custom service doesn't work

Posted by Alejandro Fernandez <af...@hortonworks.com>.
Does the user running ambari agent have permission to cat the pid file and check if that process is up?

Thanks,
Alejandro

From: Mauro Cortellazzi <ma...@radicalbit.io>>
Reply-To: "user@ambari.apache.org<ma...@ambari.apache.org>" <us...@ambari.apache.org>>
Date: Monday, February 1, 2016 at 2:06 AM
To: "user@ambari.apache.org<ma...@ambari.apache.org>" <us...@ambari.apache.org>>
Subject: Check status for custom service doesn't work

Hi All,
I'm using Ambari 2.1.2 with HDP 2.3 and I have created a custom service following this guide:
<http://mozartanalytics.com/how-to-create-a-software-stack-for-ambari/>http://mozartanalytics.com/how-to-create-a-software-stack-for-ambari/
Once the service is installed I'm able to start it and stop it with Ambari, but the check status method always said me that service is not running (but it's running).
The status function is similar to the code below (I have only change the path of the pid file):

def status(self, env):
  pid_file = "/var/run/my-service.pid"
  check_process_status(pid_file)

I've checked the file and its content: it is created in the right and it contains the correct pid.
I've checked the check_process_status code and I have seen that it does a "kill -0 <PID>", so I tried the same command in the shell and it works properly.
The python version used is 2.7.

Does anyone have a suggestion?
Many thanks for your help and your time!!
Bests.

Mauro