Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • The start script for Agents comes straightforward:

    Code Block
    languagebash
    title./build/start_jobscheduler_agent.sh: Start Script
    linenumberstrue
    collapsetrue
    #!/bin/sh
    
    JS_HOSTNAME="`hostname`"
    
    /var/sos-berlin.com/jobscheduler_agent/bin/jobscheduler_agent.sh start -http-port=4445 && tail -f /dev/null
    
    # start Agent for http port on localhost interface and for https port on network interface
    # /var/sos-berlin.com/jobscheduler_agent/bin/jobscheduler_agent.sh start -http-port=localhost:4445 -https-port=$JS_HOSTNAME:4445 && tail -f /dev/null
  • Explanations
    • Line 5: The standard start script jobscheduler_agent.sh is used. The tail command prevents the start script from terminating in order to keep the container alive.
    • Line 8: Optionally the Agent can be started for use with the HTTPS protocol on a neetwork interface and the HTTP protocol on the localhost interface.

...

  • A typical build command could look like this:

    Code Block
    languagebash
    title./build.sh: Build Command
    linenumberstrue
    collapsetrue
    #!/bin/sh
    
    set -e
    
    SCRIPT_HOME=$(dirname "$0")
    SCRIPT_HOME="`cd \"${SCRIPT_HOME}\" >/dev/null && pwd`"
    IMAGE_NAME="$(basename "$SCRIPT_HOME")"
    
    docker build --no-cache --rm --tag=$IMAGE_NAME --file=./build/Dockerfile --build-arg="USER_ID=$UID" ./build

...

  • A typical run command could look like this:

    Code Block
    languagebash
    title./run.sh: Run Command
    linenumberstrue
    collapsetrue
    #!/bin/sh
    
    set -e
    
    SCRIPT_HOME=$(dirname "$0")
    SCRIPT_HOME="`cd \"${SCRIPT_HOME}\" >/dev/null && pwd`"
    IMAGE_NAME="$(basename "$SCRIPT_HOME")"
    
    RUN_USER_ID="$(id -u $USER):$(id -g $USER)"
    
    docker run -dit --rm --user=$RUN_USER_ID --hostname=$IMAGE_NAME --network=js --publish=5445:4445 --volume=$SCRIPT_HOME/data:/var/sos-berlin.com/jobscheduler_agent/var_4445:Z --name=$IMAGE_NAME $IMAGE_NAME
  • Explanations
    • Using a common Docker network with the --network option for JobScheduler components allows direct access to resources such as ports within the Docker network.
    • The RUN_USER_ID variable is populated with the numeric ID of the account and the group that executes the run command. This value is assigned the --user option in order to inject the account information into the container (replacing the account specified with the USE jobscheduler instruction in the Dockerfile.
    • Port 4445 for access to JobScheduler Agent by a Master can optionally be mapped to some outside port. This is not required if a Docker network is used.
    • Specify a data directory to be created that is referenced with the --volume option to expose the run-time directory of the JobScheduler Agent for reading. Avoid to modify files in this directory and to add new files. 

...

  • A typical stop command could look like this:

    Code Block
    languagebash
    title./stop.sh: Stop Command
    linenumberstrue
    collapsetrue
    #!/bin/sh
    
    set -e
    
    SCRIPT_HOME=$(dirname "$0")
    SCRIPT_HOME="`cd \"${SCRIPT_HOME}\" >/dev/null && pwd`"
    IMAGE_NAME="$(basename "$SCRIPT_HOME")"
    
    JS_ACTION="stop"
    
    for option in "$@"
    do
      case "$option" in
             -kill)   JS_ACTION="kill"
                      ;;
             -abort)  JS_ACTION="abort"
                      ;;
      esac
    done
    
    JS_CONTAINER=$(docker container ps -a -q --filter "ancestor=$IMAGE_NAME")
    
    if [ -z "$JS_CONTAINER" ]
    then
      echo ".. container not running: $IMAGE_NAME"
      exit 0
    fi
    
    for f in "${JS_CONTAINER[@]}"; do
      echo ".. stopping Agent ($JS_ACTION): $f"
      docker container exec $f /bin/sh -c "/var/sos-berlin.com/jobscheduler_agent/bin/jobscheduler_agent.sh $JS_ACTION"
    
      echo ".. stopping container ($JS_ACTION): $f"
      if [ "$JS_ACTION" = "stop" ]
      then
        docker container stop $f
      else
        docker container kill $f
      fi
    done
    
  • Explanations
    • Before stopping the container the Agent daemon is terminated by use of its start script. This offers the following modes for termination:
      • stop: terminate Agent normally, wait for any running tasks to complete
      • abort: kill any running tasks and terminate the Agent abnormally
      • kill: kill immediately the Agent process and any running tasks
    • After the Agent daemon is terminated the container can be stopped or killed.

...