Actual shutdown and restart. How to differentiate?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Actual shutdown and restart. How to differentiate?

tsukit
When Glu agent executes Glu script to "stop" something (e.g. app), this could be part of an actual shutdown (where it will not try to bring that something up again right after) or it could be a part of a restart (where it will).

I have an application that needs to distinguish between these two scenarios. In Glu script, how do I do that?
Reply | Threaded
Open this post in threaded view
|

Re: Actual shutdown and restart. How to differentiate?

frenchyan
Administrator
There is currently no built-in way to distinguish. The trick is it is hard for glu to know what your intentions are: if you go in the UI and do "stop", then 10s later you do a "undeploy", you did shutdown the app but the first stop does not know that.

I suppose glu could send the "command" that was issued part of the arguments to the call and let you decide what to do with it. At this time, it does not and would require code change to make it happen.

glu already supports passing arguments:

def stop = { args ->
   args.xxxx
}

it would be a matter of figuring out what to pass.

Yan


Reply | Threaded
Open this post in threaded view
|

Re: Actual shutdown and restart. How to differentiate?

tsukit
frenchyan wrote
glu already supports passing arguments:

def stop = { args ->
   args.xxxx
}

it would be a matter of figuring out what to pass.
I'm controlling Glu server totally via its REST interface. How can pass the argument if that's possible?

Also, since I use REST interface to create plans and define the plan type when doing that, can Glu script see the plan type?
Reply | Threaded
Open this post in threaded view
|

Re: Actual shutdown and restart. How to differentiate?

frenchyan
Administrator
As can be seen in this code: https://github.com/pongasoft/glu/blob/master/orchestration/org.linkedin.glu.orchestration-engine/src/main/java/org/linkedin/glu/orchestration/engine/planner/impl/SingleStepTransition.java#L162 it is currently ignored


public class AddArgumentsPlugin {

  def PlannerService_post_computePlans = { args ->

    if(args.params.planType == 'your plan type') {
      args.serviceResult?.each { Plan plan ->
        plan.leafSteps.findAll { it.action instanceof ScriptTransitionActionDescriptor }.each { step ->
             // your action args that will be propagated to the script!
             step.action.actionArgs = [xxx: 'yyy']
          }
        }
      }
    }

    return null
  }
}

In the end it is not that much code!


Yan