Support Questions

Find answers, ask questions, and share your expertise

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

avatar

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
1 ACCEPTED SOLUTION

avatar
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.

View solution in original post

2 REPLIES 2

avatar
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.

avatar

Thanks for the reply. dlo.

It works.