oglimmer/fulgens

View on GitHub
classes/plugins/ShellPlugin.tmpl

Summary

Maintainability
Test Coverage

{{ header }}

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

{{ preparecomp }}

{{ getsource }}

{{ prestart }}

if [ "${{typeSourceVarName}}" == "local" ]; then
  if [ ! -f "{{pidFile}}" ]; then
    verbosePrint "nohup {{StartRpld}} 1>>localrun/{{softwareComponentName}}.log 2>>localrun/{{softwareComponentName}}.log &"
    {{AllEnvVarsShell}}
    nohup "{{StartRpld}}" 1>>"localrun/{{softwareComponentName}}.log" 2>>"localrun/{{softwareComponentName}}.log" &
    {{pid}}=$!
    echo "${{pid}}">"{{pidFile}}"
  else 
    {{pid}}=$(<"{{pidFile}}")
    echo "Reusing already running instance ${{pid}}"
  fi
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|removeTicks}} {{AllEnvVarsDocker|removeTicks}} -v $(pwd):/home/node/exec_env -w /home/node/exec_env {{DockerImage}}:${{typeSourceVarName}}_VERSION /bin/bash -c ./{{StartRpld|removeTicks}}"
    {{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 ./{{StartRpld}})
    echo "${{dcId}}">"$BASE_PWD/{{pidFile}}"
  else
    {{dcId}}=$(<"$BASE_PWD/{{pidFile}}")
    echo "Reusing already running instance ${{dcId}}"
  fi
fi

{{ poststart }}

{{ leavecomp }}

fi