The documentation from version 39.5.17 of PLANTA project can be found in the new PLANTA Online Help.

Setting Up Batch Run

Note
  • In PLANTA project, the so-called Headless Client is used to create a batch job.

Step 1: Create a User in PLANTA project

Procedure

Step 2: Create/Install a Macro with the Required Functionality

Procedure

  • Create a new module in the Modules module
  • Complement Python macro for the intended purpose.
  • For the batch user, this module can be defined as Startup macro that is run every time this user logs on.
    • Alternatively, you can specify the module ID in the start script of the headless client in the PLANTA_MODULE parameter (see here).

Step 3: Start the Headless Client Manually in Order to Create the Password File

Procedure
  • Open template
    • Note: this command, as well as its following examples, are single-rowed and may only be split for readability purposes
<Python Interpreter> <Headless Path>planta_headless.py --service=<Server>:<Port> --user=<BATCH User> --auth_type=challenge --secret=<PW File>

Parameter Description Example Windows Example Linux
<Python Interpreter> Opening the corresponding Python interpreters C:\Python27\python.exe /usr/local/bin/python2.7
<Headless path> Directory path headless clients, absolute:
or based on the current directory:
C:\PLANTA\Jobs\Headless\
.\
/planta/jobs/headless/
./
<Server> Name or IP Address of the PLANTA Server localhost (if it is run on an application server)
planta4711.planta.de
10.210.47.11
<Port> Service connection port Default is 21000 + System no., e.g. 21001
<BATCH-User> Name of the PLANTA project batch user BATCH
<PW-Datei> Path and name of the password file to be created .\auth_file ./auth_file

Example Windows

C:\Python27\python.exe C:\PLANTA\Jobs\Headless\planta_headless.py --service=planta4711:21001 --user=BATCH --auth_type=challenge --secret=C:\PLANTA\Jobs\Headless\auth_file

Example Linux

/usr/local/bin/python2.7 ./planta_headless.py --service=localhost:21210 --user=BATCH --auth_type=challenge --secret=./auth_file

  • Password input (password is saved to an encrypted file)
  • Set the rights for the newly created encrypted password file (editing/reading rights only for the user running the Python program).

Step 4: Configure Job

Procedure
  • For this purpose, adjust the following Shell/Batch script templates:
    • For the following script, enter the appropriate values in the adjust parameter section
    • save as a file (e.g. named Headless.bat under Windows or named headless.bsh under Linux) in the headless cient directory (the date stamp here depends on the local format and must be adjusted if necessary).
  • Example for Windows
@ECHO OFF
REM BATCH
REM PLANTA headless client: Running batch jobs
Adjust REM parameter:
REM --->
SET PYTHON="<Path to Python (V. 2.6 or 2.7)>"
SET HEADLESS_DIR="<Path to headless client (PLANTA_PY)>"
SET SERVICE=<Serveraddress:Port number>
SET USER=BATCH
REM This parameter remains empty if the work packet is defined as the start module of the batch user
REM otherwise the module ID of the module to be run is entered here:
SET PLANTA_MODULE=
IF NOT "%PLANTA_MODULE%"=="" SET MODULE_PARAM=--module=%PLANTA_MODULE%
IF "%PLANTA_MODULE%"=="" SET MODULE_PARAM=
REM If logging is required
REM and activate the script call with logging and deactivate the one without logging:
REM SET LOG_DIR="<Path of the log directory>"
REM SET LOGFILE="<Prefix for the log file (e.g. PLANTA_headless)>"
REM SET DATETIME=%DATE:~-4%-%DATE:~3,2%-%DATE:~0,2%_%TIME:~0,2%-%TIME:~3,2%-%TIME:~6,2%
REM <---
SET AUTH_FILE=".\auth_file"
SET PLANTA_PY=".\planta_headless.py"
SET PLANTA_SH=%PLANTA_PY% --service=%SERVICE% --user=%USER% --auth_type=challenge --secret=%AUTH_FILE% --module=%PLANTA_MODULE%
cd %HEADLESS_DIR%
REM variant without logging:
%PYTHON% %PLANTA_SH% %*
REM variant with logging:
REM forfiles -p %LOG_DIR% -m %LOGFILE%*.log -d -7 -c "cmd /c del @path"
REM %PYTHON% %PLANTA_SH% %* --timeout=-1 -vvv >> %LOG_DIR%\%LOGFILE%_%DATETIME%_%USER%.log
  • Example for Linux:
#!/bin/bash
# PLANTA Headless Client: Running batch jobs
# Adjust parameter:
# --->
PYTHON="<Path to Python (V. 2.6 or 2.7)>"
HEADLESS_DIR="<Headless client path (PLANTA_PY)>"
SERVICE="<Serveraddress:Portnr.>"
USER="BATCH"
# If the work packet is defined as the batch user's start module, the following parameter remains empty,
# otherwise the module ID of the module to be run is entered:
PLANTA_MODULE=""

if [[ -z $PLANTA_MODULE ]]
then
MODULE_PARAM=""
else
MODULE_PARAM="--module=$PLANTA_MODULE"
fi

# If logging is required, activate the following variables, 
# and activate the script call with logging and deactivate the one without logging below:
#LOG_DIR="<Log directory path"
#LOGFILE="<Prefix for the log file name (e.g. PLANTA_Headless)>"
#DATETIME=`date +20%y-%m-%d_%H-%M-%S`
# <---
AUTH_FILE="./auth_file"
PLANTA_PY="planta_headless.py"
PLANTA_SH="./$PLANTA_PY --service=$SERVICE --user=$USER --auth_type=challenge --secret=$AUTH_FILE $MODULE_PARAM"
cd $HEADLESS_DIR
# Variant without logging:
$PYTHON $PLANTA_SH $*
# Variant with logging:
#find $LOG_DIR -type f -name "$LOGFILE*.log" -mtime +7 -print0 | xargs -0 rm -f
#$PYTHON $PLANTA_SH $* --timeout=-1 -vvv >> $LOG_DIR/$LOGFILE\_$DATETIME\_$USER.log

Step 5: Configure the Time-Controlled Start

Note
  • Here, administrator rights are required

Procedure

  • Setup
    • under Windows: via Task Manager (or Task Planning)
    • under Linux: as a Cron Job
  • In both cases, the job does not know about environment variables, etc. All it needs to know, has to be included in the shell-scripts (e.g. using absolute paths).

Notes

  • The headless client usually starts a PLANTA macro without waiting for its completion.
  • This can be prevented via the timeout=-1 parameter.
  • In this case, the headless client waits for the macro to be completed.
  • See also the logging variant in the shell scripts mentioned above.

         PLANTA project









 
  • Suche in Topic-Namen

  • Suche in Topic-Inhalten
This site is powered by the TWiki collaboration platform Powered by Perl