Skip to content

ow.oJob

Nuno Aguiar edited this page Dec 29, 2017 · 2 revisions

oJob.__addLog

oJob.__addLog(aOperation, aJobName, aJobExecId, anErrorMessage) : String

Adds a new log entry to the channel oJob::log for the aJobName provided for the following operations:

  • start (start of a job)
  • success (successfully end of a job)
  • error (erroneous end of a job)
  • depsfail (job not started do to failed dependencies)

Optionally, for the operation error, you can provide also anErrorMessage.
Returns the current aJobExecId (or the created one for the operation start).

oJob.addTodos

oJob.addTodos(aTodoList, aId) : oJob

Adds a new aTodoList array of job names. Optionally you can provide aId to segment these specific jobs.


oJob.getID

oJob.getID() : String

Returns this oJob instance ID. Useful to lookup logging in the oJob::log channel.


oJob.load

oJob.load(aJobsList, aTodoList, aoJobList, args, aId)

Loads a set of aJobsList, corresponding aTodoList and a list of aoJobList. Optionally you can provide aId to segment these specific jobs.


oJob.oJob

oJob.oJob() : oJob

Creates an instance of an oJob. O Uses the channel oJob::log for job logging, oJob::jobs for job register, oJob::todo as job todo register and oJob::oJob for oJob instances registry.


oJob.removeJob

oJob.removeJob(aJobName) : oJob

Removes aJobName.


oJob.setJob

oJob.setJob(aJobName, aJob) : oJob

Adds or overwrites an existing aJobName with the configuration aJob.


oJob.start

oJob.start(args, shouldStop, aId) : oJob

Starts the todo list. Optionally you can provide arguments to be used by each job. Optionally you can provide aId to segment these specific jobs.


oJob.stop

oJob.stop()

Stops all oJob processing.


ow.oJob.addJob

ow.oJob.addJob(aJobsCh, aName, jobDeps, jobType, aJobTypeArgs, jobArgs, jobFunc, jobFrom, jobTo, jobHelp)

Provided aJobsCh (a jobs channel) adds a new job with the provided aName, an array of jobDeps (job dependencies), a jobType (e.g. single, peoridic, shutdown), aJobTypeArgs (a map), jobArgs and a jobFunc (a job function).  Optionally you can inherit the job definition from a jobFrom and/or jobTo name ("from" will execute first, "to" will execute after). Also you can include jobHelp.


ow.oJob.addTodo

ow.oJob.addTodo(aOJobID, aJobsCh, aTodoCh, aJobName, aJogArgs, aJobType, aJobTypeArgs)

Provided aOJobID (a oJob instance), aJobsCh (a jobs channel), aTodoCh (a todo channel), aJobArgs (job arguments). Optionally you can force the aJobType and aJobTypeArgs.


ow.oJob.getJobsCh

ow.oJob.getJobsCh() : Channel

Gets the oJob::jobs channel


ow.oJob.getLogCh

ow.oJob.getLogCh() : Channel

Gets the oJob::log channel


ow.oJob.getMainCh

ow.oJob.getMainCh() : Channel

Gets the oJob::oJob channel


ow.oJob.getTodoCh

ow.oJob.getTodoCh() : Channel

Gets the oJob::todo channel


ow.oJob.loadFile

ow.oJob.loadFile(aFile, aId)

Loads the configuration from a YAML or JSON aFile and loads all configuration.
Optionally you can provide aId to segment these specific jobs.

Example of YAML:

Name your includes

#
include:
 - hello.js   # Some nice hello function

Define the jobs

jobs:
  # Start processing
  - name        : Start processing
    exec        : >
       log("init");
       //sprint(ow.oJob.getJobsCh().getAll());

Stop processing

  - name        : Stop processing
    type        : shutdown
    exec        : >
       log("done");
       sprint(ow.oJob.getLogCh().getAll());

Hello world after start processing

  - name      : Hello world
    deps          :
       - Start processing
    exec      : >
       sprint(args);  
       hello("nuno");

Bye world

  - name        : Bye
    deps        :
       - Hello world
       - Say the time
    exec        :
       print("bye, nice to meet you.");

Say the time regularly

  - name        : Say the time
    type        : periodic
    typeArgs    :
       timeInterval   : 1000
       waitForFinish  : true
       cron           : "*/5 * * * * *"
    exec        : >
       print(new Date());

List what to do

todo:
  - Start processing
  - Say the time
  - Hello world
  - Bye
  - Stop processing

This will be a daemon

ojob:
  daemon: false
  unique:
     pidFile     : helloworld.pid
     killPrevious: true
  channels:
          : true
     port       : 17878
     permissions: r
     #list       :
     #  - oJob::log
     #auth       :
     #  - login: ojob
     #    pass : ojob
     #    permissions: r


ow.oJob.loadJSON

ow.oJob.loadJSON(aJSON) : Object

Loads aJSON oJob configuration and returns the processed map (with all includes processed).


ow.oJob.previewFile

ow.oJob.previewFile(aFile) : Map

Returns a map with a preview of the oJob configuration that would be executed with aFile.


ow.oJob.run

ow.oJob.run(providedArgs, aId)

Tries to run the current loaded configuration jobs (on the corresponding channels) with the provided arguments (providedArgs). Optionally you can provide aId to segment these specific jobs.


ow.oJob.runFile

ow.oJob.runFile(aFile, args, aId)

Loads aFile configuration and executes the oJob defined with the provided args. Optionally you can provide aId to segment these specific jobs.


ow.oJob.runJob

ow.oJob.runJob(aJob, provideArgs, aId)

With jobs defined try to execute/start aJob, with the provideArgs, directly passing any existing todo list.  Optionally you can provide aId to segment this specific jobs.

Clone this wiki locally