B4A.BASE.JOBI.RUN@UNIX

Summary

Object type
JOBI
Object Folder
PACKAGES/BEST4AUTOMIC/B4A.BASE/SOURCE/RUN
Title
Generic include for starting b4A modules on UNIX systems
Archive Key 1
-
Archive Key 2
-
Created
WRITER/B4A am: 2019-10-18 10:35:11
Last Modified
Andreas Büsching am: 2022-05-04 21:03:29 32 x
Last Used
-

Description

This include starts a b4A module on Unix systems

Parameter

$MODULE$
The name of the b4A module. Separated by a colon (:) names of configuration variable names can be specified. The names are the suffix of variable objects called B4A.BASE.VARA.CONFIG#

Input

Output

Example

    :include B4A.BASE.JOBI.RUN@UNIX $MODULE$ = "info.Search"

Process

:set &module# = "$MODULE$"
:define &param#, string, 2
:fill &param#[] = str_split( &module#, ":" )
:set &module# = &param#[ 1 ]
:set &configs# = &param#[ 2 ]
:define &config#, string, 10
:fill &config#[] = str_split( &configs#, "," )

! publish module name
:set &B4AB_CLASS_O# = "&module#"
:publish &B4AB_CLASS_O#, , TASK

! create configuration file
conffile=$(mktemp)
cat > $conffile << EOF
:set &num# = 1
:while &config#[ &num# ] <> ""
:  set &vara# = "B4A.BASE.VARA.CONFIG#&config#[ &num# ]"
:  set &hnd# = prep_process_var( &vara# )
:  process &hnd#
:    set &key# = get_process_line( &hnd#, 1 )
:    set &value# = get_process_line( &hnd#, 2 )
&key# = &value#
:  endprocess
:  close_process &hnd#
:  set &num# = add( &num#, 1 )
:endwhile
EOF

cat $b4a_config_file >> $conffile

! show the configuration
echo "-- b4A module"
echo "&module#"
echo "-- b4A configuration"
cat $conffile | grep -v password=
echo "-- b4A configuration"

! activate configuration file
export B4J_CONF_FILE=$conffile

:set &B4AB_ARGUMENTS_I# = "&B4AB_ARGUMENTS_I#"

! java settings
:if &B4AB_JAVA_OPTS_O# ne ""
export JAVA_OPTS="&B4AB_JAVA_OPTS_O#"
:endif
:if &B4AB_JAVA_HOME_O# ne ""
export JAVA_HOME="&B4AB_JAVA_HOME_O#"
:endif

! start the module
cd &B4AB_BIN_DIR_O#
./b4A-cli &module# &B4AB_ARGUMENTS_I#
b4a_exitcode=$?

! remove configuration file
rm $conffile
rm -f $b4a_config_file

Variable Publications

Found 1 variable publications (TASK)

Zeilennummer Scriptzeile
11 :publish &B4AB_CLASS_O#, , TASK