How to Implement custom service, add the service, stop the service:
Story: From the documentation I was able to add a service to existing stack definition in Ambari.
Issue: But I was either not able to stop the service or delete the service just in case.
https://cwiki.apache.org/confluence/display/AMBARI/Defining+a+Custom+Stack+and+Services
How did I solve the problem?
- 1.Create and Add Stack:
cd /var/lib/ambari-server/resources/stacks/HDP/2.4/services
- 2.Create a directory that contains the service definition for SAMPLESRV
mkdir /var/lib/ambari-server/resources/stacks/HDP/2.4/services/SAMPLESRV
cd /var/lib/ambari-server/resources/stacks/HDP/2.4/services/SAMPLESRV
- 3.Create a metainfo.xml as show in the link above.
- 4.With this we have a service name as SAMPLESRV and it contains SAMPLESRV_MASTER, SAMPLESRV_SLAVE and SAMPLESRV_CLIENT
- 5.Next we need to create the command scripts
mkdir –p /var/lib/ambari-server/resources/stacks/HDP/2.4/services/SAMPLESRV/package/scriptscd /var/lib/ambari-server/resources/stacks/HDP/2.4/services/SAMPLESRV/package/scripts
- 6.Browse the scripts directory and create the .py command scripts:master.py, slave.py and sample_client.py under : /var/lib/ambari-server/resources/stacks/HDP/2.4/services/SAMPLESRV/package/scripts
Master.py and slave.py


here was the issue: in the documentation it doesn’t mention about the dummy.pid that needs to be created. Since we have not installed a real service, there is no PID file created by it. Therefore, we are going to artificially create the PID, remove the PID and check the process status of the dummy pid.
- 7.Then restart ambari: ambari-server restart and add the service to the stack as shown the document. Just don't want to duplicate the process with steps here.



Hope this helps....

