Execute on Startup
 

Execute on Startup

16 posts, 1 answered
  1. Markus Grigoleit
    Markus Grigoleit avatar
    31 posts
    Registered:
    04 Jun 2019
    04 Nov 2020
    Link to this post
    I'm wondering what is the best practice to execute some task / method after the SCL has been initialized.

    For progress in general i just can call some p-file with the startup-parameter -p. But i guess this would execute before the scl starts.

    Any ideas?
  2. Roger Blanchard
    Roger Blanchard avatar
    381 posts
    Registered:
    29 Jun 2018
    04 Nov 2020 in reply to Markus Grigoleit
    Link to this post
    Are you referring to when a GUI client starts or on the appserver. We use the services.xml file to load up some application services. What do you want to do with this startup task?
  3. Markus Grigoleit
    Markus Grigoleit avatar
    31 posts
    Registered:
    04 Jun 2019
    04 Nov 2020 in reply to Roger Blanchard
    Link to this post
    Not exactly. I'm referring to the point when the appserver has startet. There's no Progress GUI-Client involved. Just a Backend with an HTTP-API.
    I want to run a loop as soon as the SCL has been initilized. This Loop will continuously run a Method from a BusinessTask.
  4. Roger Blanchard
    Roger Blanchard avatar
    381 posts
    Registered:
    29 Jun 2018
    04 Nov 2020 in reply to Markus Grigoleit
    Link to this post
    You can startup a service on the backend as well when PASOE is starting up. We use this as well and it works very nicely.
  5. Daniel van Doorn
    Daniel van Doorn avatar
    17 posts
    Registered:
    18 Jun 2018
    04 Nov 2020
    Link to this post
    I would say creating your own service is in line with the SmartComponent Library architecture. 

    However, what is the start procedure in your openedge.properties, ccs_startup.p?
    It's easy to write a small wrapper around the startup procedure. You just need to pass a character parameter. 

    When the startup procedure is finished, then the SmartComponent Library back-end is started. 
  6. Markus Grigoleit
    Markus Grigoleit avatar
    31 posts
    Registered:
    04 Jun 2019
    04 Nov 2020
    Link to this post
    what is the start procedure in your openedge.properties, ccs_startup.p?


    Yeah thats right. So i would write a p-file which calls ccs_startup.p first and then calls my service.cls?
    I did not know that i could call methods defined inside a class from a p-file.

    https://knowledgebase.progress.com/articles/Article/Can-a-procedure-be-run-from-a-class
    Last modified on 04 Nov 2020 14:11 by Markus Grigoleit
  7. Mike Fechner
    Mike Fechner avatar
    319 posts
    Registered:
    14 Sep 2016
    04 Nov 2020 in reply to Markus Grigoleit
    Link to this post
    Do you mind sharing a bit more about the use-case? What is this class supposed to do when the AppServer has started?

    I would rather go the Service routes as recommended by Roger and Daniel. 

    For certain use-cases a Service implementing the Consultingwerk.Framework.IStartupValidationService may be the right thing. That Service can verify the AppServer setup and prevent it from becoming available when you
    re not happy with the setup.
  8. Markus Grigoleit
    Markus Grigoleit avatar
    31 posts
    Registered:
    04 Jun 2019
    05 Nov 2020 in reply to Mike Fechner
    Link to this post
    Hello Mike!

    So we have a list of planned tasks with a date. We want to execute stuff whenever the datetime of a task matches today. Therefore i need some kind of loop which will run as soon as the server has been startet.

    So i did the wrapper thing for the startup like this:

    startup.p

    RUN Consultingwerk/Framework/Server/ccs_startup.p (pcParameter).
    DEFINE VARIABLE jobManagerBT AS JobManagerBusinessTask NO-UNDO.
    jobManagerBT = NEW JobManagerBusinessTask().
    jobManagerBT:startLoop()

    And changed the openedge.properties.

    It works pretty good so far except for nothing works anymore. I think it might be a problem with the loop not executing async. Have to dig into that aswell.

  9. Mike Fechner
    Mike Fechner avatar
    319 posts
    Registered:
    14 Sep 2016
    05 Nov 2020 in reply to Markus Grigoleit
    Link to this post
    Glad I asked about this.The issue with AppServer startup for that use-case is that when load increases multiple AppServer may be started during the day at unpredictable times.

    A schedule might be a better approach. We have one in the framework - but currently the maintenance of tasks is only available in the GUI application, not yet in the Angular Web application. 

  10. Markus Grigoleit
    Markus Grigoleit avatar
    31 posts
    Registered:
    04 Jun 2019
    05 Nov 2020 in reply to Mike Fechner
    Link to this post
    Yes we already looked into that and sadly we relaized that we have to make our own scheduler.

    So the right approach would be to write a Service which implements the consultingwerk service interface and load it in my own service.xml

    I found some service.xml with loaded services in the framework folder, but cant find the config where this path is mentioned. Where would i have to register additional service-files?
    Last modified on 05 Nov 2020 10:11 by Markus Grigoleit
  11. Roger Blanchard
    Roger Blanchard avatar
    381 posts
    Registered:
    29 Jun 2018
    05 Nov 2020 in reply to Markus Grigoleit
    Link to this post
    Markus,

    You are correct. If your StartLoop is in a loop I do not believe the startup procedure would ever finish. I am surprised PASOE would even start (agent)

    startup.p

    RUN Consultingwerk/Framework/Server/ccs_startup.p (pcParameter).
    DEFINE VARIABLE jobManagerBT AS JobManagerBusinessTask NO-UNDO.
    jobManagerBT = NEW JobManagerBusinessTask().
    jobManagerBT:startLoop()

    >> Where would i have to register additional service-files?

    What we did was copy the services.xml provided by CW and modifier around our needs and then distribute it. We removed what we did not need and added a few application services.
  12. Mike Fechner
    Mike Fechner avatar
    319 posts
    Registered:
    14 Sep 2016
    05 Nov 2020 in reply to Roger Blanchard
    Link to this post
    I would really recommend not to prevent the AppServer startup procedure from finishing. Running an external loop there does not sound too appealing. 

    For a scheduler, I'd really prefer to implement that in a Progress batch client session or similar. 
  13. Markus Grigoleit
    Markus Grigoleit avatar
    31 posts
    Registered:
    04 Jun 2019
    10 Nov 2020 in reply to Roger Blanchard
    Link to this post
    So you added <ttServiceLoaderRow> - elements to the Consultingwerk/SmartFramework/services.xml ?
    Would be neat if i could just create a  "ownServices.xml" and load it after the CW - services.xml. But it will do.
  14. Mike Fechner
    Mike Fechner avatar
    319 posts
    Registered:
    14 Sep 2016
    Answered
    10 Nov 2020 in reply to Markus Grigoleit
    Link to this post
    It is definitively _NOT_ recommended to modify the config files we ship. 

    Please follow those instructions: https://consultingwerk.atlassian.net/wiki/spaces/SCL/pages/8094594/JSON+Configuration+File+Format
  15. Mike Fechner
    Mike Fechner avatar
    319 posts
    Registered:
    14 Sep 2016
    10 Nov 2020 in reply to Mike Fechner
    Link to this post
    But again: Services executed at startup should return to the caller fast. 

    The AppServer startup procedure is not meant to wait for scheduled events. 

    Batch sessions (like our scheduler) are built to do that.
  16. Markus Grigoleit
    Markus Grigoleit avatar
    31 posts
    Registered:
    04 Jun 2019
    11 Nov 2020 in reply to Mike Fechner
    Link to this post
    Thanks mike! We found another solution for now.
    But sooner or later we will need to look in those Batch sessions.

16 posts, 1 answered