Hi, It's the expected behavior as only one command can run in foreground per session (the same as if you are running the command yourself in the shell). Maybe it's not clear enough in the documentation, I can improve that.
Regards JB On Mon, May 16, 2022 at 8:10 PM Paul Spencer <[email protected]> wrote: > > Karaf 4.3.6 > > If more then one command is schedule to run in the foreground, the some of > the command will fail to run with "java.lang.IllegalStateException: A job is > already in foreground". Command that are scheduled to run in the background > do not have this issue. > > Is this the intended behavior? > > Please update the documentation, > https://karaf.apache.org/manual/latest/#_schedule_a_command, on running jobs > in the background. > Where job runs Command to schedule job > --------------- > --------------------------------------------------------------- > Foreground scheduler:schedule-command --cron "0 0/1 * * * ?" "http:list" > Background scheduler:schedule-command --cron "0 0/1 * * * ?" "http:list > &" > > > > *** > * Scheduling the commands to run in the foreground > *** > karaf@root()> scheduler:schedule-command --cron "0 0/1 * * * ?" "http:list" > karaf@root()> scheduler:schedule-command --cron "0 0/1 * * * ?" > "http:proxy-list" > karaf@root()> scheduler:list > Name │ Schedule > ─────────────────────────┼────────────────────────────────────────────── > bugdataEmailReceiver.165 │ at(2022-05-16T12:22:05.378-04:00, -1, 300000) > http:proxy-list │ cron(0 0/1 * * * ?) > http:list │ cron(0 0/1 * * * ?) > > karaf@root()> ID │ Servlet │ Servlet-Name │ State │ Alias │ Url > ───┼──────────────┼──────────────┼─────────────┼───────┼───── > 86 │ Whiteboard$1 │ cxf-servlet │ Deployed │ │ [/*] > > *** > * karaf.log > *** > 13:40:00.023 WARN [Karaf_Worker-22] Error executing scheduled command > http:proxy-list > java.lang.IllegalStateException: A job is already in foreground > at > org.apache.felix.gogo.runtime.CommandSessionImpl$JobImpl.foreground(CommandSessionImpl.java:677) > ~[?:?] > at > org.apache.felix.gogo.runtime.CommandSessionImpl$JobImpl.start(CommandSessionImpl.java:794) > ~[?:?] > at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:300) > ~[?:?] > at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:169) > ~[?:?] > at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:149) > ~[?:?] > at > org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:179) > ~[?:?] > at > org.apache.karaf.shell.impl.console.ConsoleSessionImpl.execute(ConsoleSessionImpl.java:496) > ~[?:?] > at > org.apache.karaf.scheduler.command.support.CommandJob.execute(CommandJob.java:40) > [!/:?] > at > org.apache.karaf.scheduler.core.QuartzJobExecutor.execute(QuartzJobExecutor.java:58) > [!/:?] > at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [!/:?] > at > org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) > [!/:?] > > *** > * Scheduling the commands to run in the background > *** > karaf@root()> scheduler:schedule-command --cron "0 0/1 * * * ?" "http:list &" > karaf@root()> scheduler:schedule-command --cron "0 0/1 * * * ?" > "http:proxy-list &" > karaf@root()> > > > > [1] background http:proxy-list > karaf@root()> URL │ ProxyTo │ Balancing Policy > ────┼─────────┼───────────────── > [1] done http:proxy-list > karaf@root()> > > > > [1] background http:list > karaf@root()> ID │ Servlet │ Servlet-Name │ State │ Alias │ Url > ───┼──────────────┼──────────────┼─────────────┼───────┼───── > 86 │ Whiteboard$1 │ cxf-servlet │ Deployed │ │ [/*] > [1] done http:list > karaf@root()> > > Paul Spencer >
