Starting long running jobs from a command script (bxs) block other command scripts

Friday, 4 November 2016 · 3 messages · last reply 8 Nov 2016
JD
Jan Dölle4 Nov 2016 16:05 #
Hi, I'm starting a job within a command script (startup.bxs). The job is a worker running the whole life of the application. It is not possible to run an other command script (shutdown.bxs) as long the job hasn't terminated. Calling xquery-scripts (shutdown.xq) will be possible anyway. Any Idea what's blocking the shutdown.bxs command script? Thank in advanced Jan --- startup.bxs:
<commands>
    <xquery>
    Q{java:java.lang.System}setProperty("xq.machine.shutdown", "false")
    </xquery>
    <xquery><![CDATA[
jobs:eval(
    '(
     hof:until(
       function($f) {
xs:boolean(Q{java:java.lang.System}getProperty("xq.machine.shutdown") =
"true")
       },
       function($f) {
          trace( concat( prof:current-ms(), " Job: ", jobs:current() ) ),
          prof:sleep(1000)
          },
       ()
       ),
     trace( concat( prof:current-ms(), " Job: ", jobs:current(), "
shutdown" ) )
     )'
     )
       ]]></xquery>
    <jobs-list/>
    <xquery>trace("Hello")</xquery>
</commands>
shutdown.bxs (not able to run after startup.bxs):
<commands>
    <jobs-list/>
    <xquery>
    Q{java:java.lang.System}setProperty("xq.machine.shutdown", "true")
    </xquery>
</commands>
shutdown.xq (will work): Q{java:java.lang.System}setProperty("xq.machine.shutdown", "true")
-- Jan Dölle E-Mail: basex-list at id1.de Telefon +49-69-244502-0 Home: www.id1.de Information Design One AG, Baseler Straße 10, 60329 Frankfurt am Main Registereintrag: Amtsgericht Frankfurt am Main, HRB 52596 Vorstand: Robert Peters, Aufsichtsrat: Christian Hecht (Vorsitz)
CG
Christian Grün8 Nov 2016 08:39 #
Hi Jan, Finally some feedback to you as well:
Quoted text · Jan Dölle · 1 line
> Any Idea what's blocking the shutdown.bxs command script?
Interestingly, I can stop your first script with both the shutdown script and the XQuery expression (provided that I am running them from an interactive BaseX console; when calling "basex startup.bxs", the job will already by stopped as soon the BaseX Java process quits). Which version of BaseX are you using? How exactly did you proceed to start the scripts? Cheers, Christian
CG
Christian Grün8 Nov 2016 08:42 #
PS: The recommended way to stop BaseX jobs is to remember the job id and terminate the job via job:stop. This process will be graceful in a sense that the query processor thread itself will decide when to stop. Updates, for example, will always be completed successfully when calling job:stop.
Quoted text · Christian Grün · 18 lines
On Tue, Nov 8, 2016 at 8:39 AM, Christian Grün <christian.gruen at gmail.com> wrote: > Hi Jan, > > Finally some feedback to you as well: > >> Any Idea what's blocking the shutdown.bxs command script? > > Interestingly, I can stop your first script with both the shutdown > script and the XQuery expression (provided that I am running them from > an interactive BaseX console; when calling "basex startup.bxs", the > job will already by stopped as soon the BaseX Java process quits). > > Which version of BaseX are you using? How exactly did you proceed to > start the scripts? > > Cheers, > Christian

⚡Generated with XQuery