Versions Compared

Key

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

...

  • 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)"
    
    mkdir -p $SCRIPT_HOME/data
    
    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. 

Stop

There are a number of ways how to stop terminate an Agent and its container, find the following example:

  • 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 Only after the Agent daemon is terminated the container can be stopped or killed.

...