Results 1 to 8 of 8

Thread: How to update while a SERVICE is installed / running?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default How to update while a SERVICE is installed / running?

    Hello all,

    how do I have to handle an installed and (possibly) runnig background service,
    when I install an update over it?

    Is STOPping that service sufficient or does I also have to REMOVE this service,
    then, at the end of the installation, re-install and re-start it?

    My idea is this:

    at that begin of the installation process I check for the service to run:

    For being installed
    Set Variable %SERVICE_IS_INSTALLED% to FUNCTION:Check Service ("MyServer") [Is Installed]

    For also running:
    Set Variable %SERVICE_IS_RUNNING% to FUNCTION:Check Service ("MyServer") [Is Running]

    Now:
    If %SERVICE_IS_INSTALLED% Equals "1" Then
    If %SERVICE_IS_RUNNING% Equals "1" Then
    Run Command Line ("SC STOP MyServer") [Wait] [Show or not]
    END
    Run Command Line ("SC QUIT KiKSOAPServer") [Wait] [Show]
    END

    ... now do a lot of fiddlefaddle ...

    and finally at the end of the script, in the [ Execute Programs ]-section,
    restoer the service according to the values from the top:

    If %SERVICE_IS_INSTALLED% Equals "1" Then ! it WAS installed when we entered this process
    Run Command Line ("x:\MyServer.EXE /iss") [Wait] [Show or not]
    END


    If %SERVICE_IS_RUNNING% Equals "1" Then ! it WAS also running when we entered this process
    Run Command Line ("SC START MyServer") [Wait] [Show or not]
    END

    Now the state of the service should be restored to the same conditions at
    starttime of the update-install.

    Is that a possible way to handle the installation over an installed / running service?

    Thanks in advance!


    Regards,
    Wolfgang Orth
    www.odata.de

    Please note:
    From time to time it happens, that I overlook a reply to my postings.
    Please don't be angry.
    In case of an emergency, try to contact me via mail.

    Bitte beachten:
    Von Zeit zu Zeit passiert es mir, dass ich Antworten auf meine Postings übersehe.
    Bitte nicht böse sein.
    Im Notfall bitte Kontakt per Mail versuchen.

  2. #2

    Default Re: How to update while a SERVICE is installed / running?

    Hi Wolfgang,

    What about using the built-in "Edit Service..." script function to stop and
    restart the service?

    Detect an installed service. If it is installed and running, stop the
    service (give it a few seconds to close down, check again if it is running),
    then replace the service file(s) and restart it.

    Friedrich

  3. #3

    Default Re: How to update while a SERVICE is installed / running?

    >Hi Wolfgang,
    >
    >What about using the built-in "Edit Service..." script function to stop and
    >restart the service?
    >

    Seems simpler, have not seen these (I think)

    Is STOP and and RESTART sufficient? No need to REMOVE?

    The process of running a service is a Windows OS thing, the installation is one
    thing on its own by SB, so its independent. When the service is stopped, then
    SB can stop the EXE from running, replace that file with the new version,
    restart the EXE and _then_ advise the OS restart that service again, which is
    actually the new EXE. This Services.MSC does not care, if an EXE is replaced,
    while that service is stopped? Because Service.MSC does nothing more than
    watching a list of services.

    An INSTALL SERVICE puts an EXE onto that list.
    A START SERVICE - well, yes, starts it, but can do only, if is was set onto the
    list before.
    A STOP SERVICE - aehh, well, aehh, yes - stops it. However, the EXE is still
    running, because I can see it in the TaskManager. But SB takes care of that. SB
    removes the running EXE, replaces it with the new from the installer, runs this
    new EXE and then issues a START, which is nothing but telling the OS to
    activate this EXE as a service again. Services.MSC looks on its list, sees my
    EXE been listed and says "Oh yeah, the EXE is known to me, its running, lets
    make it a service again!"

    Is my impression correct?


    >Detect an installed service. If it is installed and running, stop the
    >service (give it a few seconds to close down, check again if it is running),
    >then replace the service file(s) and restart it.

    Like

    LOOP ! with no limits or with some iterations
    Set Variable %SERVICE_IS_RUNNING% to FUNCTION:Check Service ("MyService") [Is Running]
    SET counter
    IF %SERVICE_IS_RUNNING% = 0 ! then its not running anymore
    BREAK LOOP
    ELSE
    some counter eval to issue a break, before the morning dawns
    END
    END

    If I choose iterations, how many do you suggets? Is it based on
    (milli/hundreths-)Seconds or just a raw number?

    Number of Iterations
    [in] Executes Number of Iterations times.
    This can be a numeric constant, a compiler
    variable or a runtime variable. Leave this
    field empty if you wish the Loop to run
    continuously. In such cases, you plan to
    Break Loop based on some condition you
    expect to always happen.

    So, how fast is one LOOP-cycle, how long does it take between two cycles of a loop?


    Sounds reasonable and actually what I wanted to achive. There are actually too
    many options to pick from the right hand menu! <g>



    Ich hab echt ein schlechtes Gewissen, dich zu löchern, denn Du solltest
    eigentlich aufm Sofa liegen....

    Ach, und wo ich grade dabei bin, ist meine Mail letzte Woche durchgekommen?

    Regards,
    Wolfgang Orth
    www.odata.de

    Please note:
    From time to time it happens, that I overlook a reply to my postings.
    Please don't be angry.
    In case of an emergency, try to contact me via mail.

    Bitte beachten:
    Von Zeit zu Zeit passiert es mir, dass ich Antworten auf meine Postings übersehe.
    Bitte nicht böse sein.
    Im Notfall bitte Kontakt per Mail versuchen.

  4. #4

    Default Re: How to update while a SERVICE is installed / running?

    Probably best not to remove. If it was installed with specific
    credentials, you'd want those credentials to remain intact.

    >No need to REMOVE?

    Jeff Slarve
    www.jssoftware.com

    you know what happens when you assuage

  5. #5

    Default Re: How to update while a SERVICE is installed / running?

    check for in-use files too. Sometimes it can end up in a hung state.

    >check again if it is running),

    Jeff Slarve
    www.jssoftware.com

    you know what happens when you assuage

  6. #6

    Default Re: How to update while a SERVICE is installed / running?

    Hi Wolfgang,

    > Is STOPping that service sufficient or does I also have to REMOVE this service,
    > then, at the end of the installation, re-install and re-start it?
    STOPping the service is enough to overwrite the exe. It terminates the
    service EXE but leaves it in the service list.

    Best regards,


    --
    Arnor Baldvinsson
    Icetips Alta LLC

  7. #7

    Default Re: How to update while a SERVICE is installed / running?

    >Hi Wolfgang,
    >
    >On 3/13/2018 09:38 AM, Wolfgang Orth wrote:
    >
    >> Is STOPping that service sufficient or does I also have to REMOVE this service,
    >> then, at the end of the installation, re-install and re-start it?
    >STOPping the service is enough to overwrite the exe. It terminates the
    >service EXE but leaves it in the service list.

    Thats what I thought. But short and concise! See my other post, were I wrote
    exact these with lengthy blabla.

    Looking at the timestamp of your post, it took me more than 30 minute to mangle
    my thoughts out of my brain.

    Thanks, Arnor!

    Regards,
    Wolfgang Orth
    www.odata.de

    Please note:
    From time to time it happens, that I overlook a reply to my postings.
    Please don't be angry.
    In case of an emergency, try to contact me via mail.

    Bitte beachten:
    Von Zeit zu Zeit passiert es mir, dass ich Antworten auf meine Postings übersehe.
    Bitte nicht böse sein.
    Im Notfall bitte Kontakt per Mail versuchen.

  8. #8

    Default Re: How to update while a SERVICE is installed / running?

    If you're going to use SB to do your service stuff, why not use the
    built-in service stuff instead of the commandline?

    Also, you could write a support DLL that uses SelfService to do that
    stuff for you in Clarion code.

    Jeff Slarve
    www.jssoftware.com

    you know what happens when you assuage

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •