R/q.R

Defines functions q.show

# scan log dir, show status of jobs
# manage re-rescheduling recycle
#

# start job dispatcher
# job.dispatcher()
# job.shutdown()


q.show <- function()
  # queue of job list
{

  .scan.log <- function (wdir=.pkg.log$log.dir)
  {

    if(!file.exists(wdir)) return(NULL)

    ppath <- function(name){
      return(sprintf("%s/%s",wdir,name))
    }

    .pkg.log$inbox    <<- dir(ppath(name='inbox'),   full.names = TRUE, recursive = TRUE)
    .pkg.log$outbox   <<- dir(ppath(name='outbox'),  full.names = TRUE,recursive = TRUE)
    .pkg.log$progress <<- dir(ppath(name='progress'),full.names = TRUE,recursive = TRUE)
    .pkg.log$schedule <<- dir(ppath(name='schedule'),full.names = TRUE,recursive = TRUE)
    .pkg.log$failed <<- dir(ppath(name='failed'),full.names = TRUE,recursive = TRUE)
  }

  # scan and update job ticket in log directory
  .scan.log()

  # count ticket in different status
  ret <- data.frame(
    n.quene   = length(.pkg.log$inbox) + length(.pkg.log$schedule),
    n.running = length(.pkg.log$progress),
    failed=length(.pkg.log$failed),
    inbox  = length(.pkg.log$inbox),
    outbox = length(.pkg.log$outbox),
    schedule = length(.pkg.log$schedule),
    n.sleep   = .pkg.log$n.sleep
  )

  return(ret)
}
okux/qrmarkdown documentation built on Dec. 22, 2021, 4:17 a.m.