Reply
Explorer
Posts: 9
Registered: ‎03-27-2015
Accepted Solution

How to install some of the dependencies prior to start the custom service(just one time)

[ Edited ]

Hello All, I am building a custom Service using CSD.  I want to install some of the dependencies prior to start the service(just one time) for. example installation of drivers, starting database servers etc. . I am doing that by calling a shell script prior to exec. But the problem is whenever there is a call to start to the service all the pre strart process run again. How can i achieve this.

 

#!/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
Cloudera Employee
Posts: 508
Registered: ‎07-30-2013

Re: How to install some of the dependencies prior to start the custom service(just one time)

Create an initialization command and reference it in your SDL in serviceInit (see https://github.com/cloudera/cm_ext/wiki/Service-Descriptor-Language-Reference#serviceinit).

Move all of your one-time initialization logic to that command.
Highlighted
Explorer
Posts: 9
Registered: ‎03-27-2015

Re: How to install some of the dependencies prior to start the custom service(just one time)

Thanks for the reply. dlo.

It works.

Announcements