Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Unable to Stop Custom Service through Cloudera Manager

avatar

Hello All, I have build a custom service. I am doing some pre task (installation of drivers, start database  and other daemon services etc) before calling exec.This service started succefully.  

Duing stop from Cloudera Manager , along with the service started with exec I wanto stop the services started in pre task also.for that .I have written a script to stop all the daemon services 

But I found that the only the  service which is started with exec  stops not in the pre-task.

 

Please Guide me , how to solve the isuue.

 

My service.sdl is as foolows

 

{
  "name" : "MYAPP",
  "label" : "Myapp",
  "description" : "My App Custom CSD",
  "version" : "2.1",
 "runAs" : {
    "user" : "root",
    "group" : "root"
   },
 "maxInstances" : 1,
 "icon" : "images/myapp.png",

  "parcel" : {
        "repoUrl" : "http://xx.xx.xx.xx:xxxx/latest/",
        "requiredTags" : [ "myapp" ]
 },
   "roles" : [
    {
       "name" : "MY_WEBSERVER",
       "label" : "My Web Server",
       "pluralLabel" : "My Web Server",
       "startRunner" :
        {
         "program" : "scripts/control.sh",
         "args" : [ "start" ]
        },
      "stopRunner" :
        {
                "relevantRoleTypes" : ["MY_WEBSERVER"],
                "runner" :
                {
                "program" : "scripts/control.sh",
                "args" : ["stop"]
                },
                "timeout" : 180000,
                "masterRole" : "MY_WEBSERVER"
        },

        "topology" :
        {
                "minInstances" : "1",
                "maxInstances" : "1"
        },
        "logging" :
        {
                "dir" : "/var/log/myapp-2.1/",
                "filename" : "myapp.log"
        }
    }
  ]
}

and my control.sh is as follows-

#!/bin/bash
CMD=$1

case $CMD in
  (start)
    echo "Starting the MyAPP Service"

        cp -r  /opt/cloudera/parcels/myapp-2.1 /opt/
       
        chmod 777 -R /opt/myapp-2.1/
        sh /opt/myapp-2.1/resource/scripts/installer/MainScript
        exec python -m SimpleHTTPServer 8080
    	;;
  (stop)
   	sh /opt/myapp-2.1/resource/scripts/installer/StopAll
   	;;
  (restart)
   	sh /opt/myapp-2.1/resource/scripts/installer/RestartAll
   	;;

  (*)
    	echo "Don't understand [$CMD]"
    	;;
esac

 

1 ACCEPTED SOLUTION

avatar
It looks like you're starting a process in the background. Cloudera Manager expects that the shell script used to start the role will "exec" the real process. Cloudera manager only tracks the process that it spawns. If you fork a process and then exit your shell script, it will appear as if the process CM just spawned has died unexpectedly, which causes CM to try and start it again.

View solution in original post

5 REPLIES 5

avatar
It's best if all roles are associated with a single process. It looks like you're spawning 2 processes for a single role. This messes up things like monitoring and makes it so that stop commands don't work (as you noticed).

It's common to split these two processes into separate roles to solve this problem.

avatar

Thanks for the reply. I am new to cloudera manager and CSD.

I tried by spliiting the process into roles.

In the role`s startrunner  i have written to start one of my linux service, but the the role failed to start as Cloudera Manager attemped multiple times to start the same. First time it succeeded to start the service but then it attemped again multiple times and found the service is already running and thus failed to start. Please Guide me.

 

Following is the stdout 

 

Fri May  8 01:26:13 EDT 2015
JAVA_HOME=/usr/java/jdk1.7.0_67-cloudera
Using /var/run/cloudera-scm-agent/process/887-xx-xx_SERVICE as conf dir
Using scripts/control.sh as process script
Starting the xx service
xx Service StartsStarting xx-service service: xxservice started ...
[  OK  ]

Fri May  8 01:26:16 EDT 2015
JAVA_HOME=/usr/java/jdk1.7.0_67-cloudera
Using /var/run/cloudera-scm-agent/process/887-xx-xx_SERVICE as conf dir
Using scripts/control.sh as process script
Starting the xx service
xx Service Starts xx-service already running

Fri May  8 01:26:18 EDT 2015
JAVA_HOME=/usr/java/jdk1.7.0_67-cloudera
Using /var/run/cloudera-scm-agent/process/887-xx-xx_SERVICE as conf dir
Using scripts/control.sh as process script
Starting the xx service
xx Service Starts xx-service already running

Fri May  8 01:26:21 EDT 2015
JAVA_HOME=/usr/java/jdk1.7.0_67-cloudera
Using /var/run/cloudera-scm-agent/process/887-xx-xx_SERVICE as conf dir
Using scripts/control.sh as process script
Starting the xx service
xx Service Starts xx-service already running

 

avatar
It looks like you're starting a process in the background. Cloudera Manager expects that the shell script used to start the role will "exec" the real process. Cloudera manager only tracks the process that it spawns. If you fork a process and then exit your shell script, it will appear as if the process CM just spawned has died unexpectedly, which causes CM to try and start it again.

avatar

avatar

Thanks dlo,

You were correct, my service were daemons which was causing the issue.

I made them to run in forground and everything just works fine.