Starting long running jobs from a command script (bxs) block other command scripts
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@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)
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
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. On Tue, Nov 8, 2016 at 8:39 AM, Christian Grün <christian.gruen@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
participants (2)
-
Christian Grün -
Jan Dölle