oglimmer/fulgens

View on GitHub
classes/plugins/JavaPlugin.tmpl

Summary

Maintainability
Test Coverage

{{ header }}

if [ "$START_{{softwareComponentName|upper}}" = "YES" ]; then

{{ preparecomp }}

{{ getsource }}

{{ prestart }}

if [ "${{typeSourceVarName}}" == "local" ]; then
    OPWD="$(pwd)"
    cd "$(dirname "{{ArtifactRpld}}")"
    if [ ! -f "$BASE_PWD/{{pidFile}}" ]; then
      verbosePrint "nohup "./$(basename "{{ArtifactRpld}}")" 1>>"$BASE_PWD/localrun/{{softwareComponentName}}.log" 2>>"$BASE_PWD/localrun/{{softwareComponentName}}.log" &"
      {{AllEnvVarsShell}} nohup "./$(basename "{{ArtifactRpld}}")" 1>>"$BASE_PWD/localrun/{{softwareComponentName}}.log" 2>>"$BASE_PWD/localrun/{{softwareComponentName}}.log" &
      {{pid}}=$!
      echo "${{pid}}">"$BASE_PWD/{{pidFile}}"
    else 
      {{pid}}=$(<"$BASE_PWD/{{pidFile}}")
      echo "Reusing already running instance ${{pid}}"
    fi
    cd "$OPWD"
fi
if [ "${{typeSourceVarName}}" == "docker" ]; then
    #if [ -f "$BASE_PWD/{{pidFile}}" ] && [ "$(<"$BASE_PWD/{{pidFile}}")" == "download" ]; then
    #  echo "node running but started from different source type"
    #  exit 1
    #fi
    if [ ! -f "$BASE_PWD/{{pidFile}}" ]; then
        startDockerNetwork
        {{writeDockerConnectionLogic}}
        {{writeConfigFiles}}
        verbosePrint "docker run --rm -d -p {{ExposedPort}}:{{ExposedPort}} {% if DockerMemory %}-m {{DockerMemory}}{% endif %} --net={{systemName|lower}}net --name={{softwareComponentName}} $ADD_HOST_INTERNAL {{mountToDocker}} {{AllEnvVarsDocker}} -v "$(pwd)":/home/node/exec_env -w /home/node/exec_env {{DockerImage}}:${{typeSourceVarName}}_VERSION /bin/bash -c ./{{ArtifactRpld}}"
        {{dcId}}=$(docker run --rm -d -p {{ExposedPort}}:{{ExposedPort}} \
            {% if DockerMemory %}-m {{DockerMemory}}{% endif %} \
            --net={{systemName|lower}}net --name={{softwareComponentName}} $ADD_HOST_INTERNAL \
            {{mountToDocker}} {{AllEnvVarsDocker}} \
            -v "$(pwd)":/home/node/exec_env -w /home/node/exec_env {{DockerImage}}:${{typeSourceVarName}}_VERSION /bin/bash -c ./{{ArtifactRpld}})
        echo "${{dcId}}">"$BASE_PWD/{{pidFile}}"
    else
        {{dcId}}=$(<"$BASE_PWD/{{pidFile}}")
        echo "Reusing already running instance ${{dcId}}"
    fi
fi

{{ poststart }}

{{ leavecomp }}

fi