protected ExecuteConnectionAsset()

in packages/aws-rfdk/lib/deadline/lib/rq-connection.ts [103:153]


  protected ExecuteConnectionAsset(host: IHost, args: ConnectionScriptArguments) {

    const hostStack = Stack.of(host);
    const connectionAsset = this.connectionAssetSingleton(hostStack);
    connectionAsset.grantRead(host);

    const configureScriptPath = host.userData.addS3DownloadCommand({
      bucket: connectionAsset.bucket,
      bucketKey: connectionAsset.s3ObjectKey,
    });

    const dlExtraCommands = [];
    if (args.tlsCaArn) {
      dlExtraCommands.push( '--tls-ca', `"${args.tlsCaArn}"` );
    }
    if ( host.osType === OperatingSystemType.LINUX ) {

      host.userData.addCommands(
        'if [ -f "/etc/profile.d/deadlineclient.sh" ]; then',
        '  source "/etc/profile.d/deadlineclient.sh"',
        'fi',
        `"\${DEADLINE_PATH}/deadlinecommand" -executeScriptNoGui "${configureScriptPath}" --render-queue "${args.address}" ${dlExtraCommands.join(' ')}`,
        // Cleanup
        `rm -f "${configureScriptPath}"`,
      );
      if (args.restartLauncher ?? true) {
        host.userData.addCommands(
          'if service --status-all | grep -q "Deadline 10 Launcher"; then',
          '  service deadline10launcher restart',
          'fi',
        );
      }
    } else if ( host.osType === OperatingSystemType.WINDOWS ) {
      host.userData.addCommands(
        '$ErrorActionPreference = "Stop"',
        '$DEADLINE_PATH = (get-item env:"DEADLINE_PATH").Value',
        `& "$DEADLINE_PATH/deadlinecommand.exe" -executeScriptNoGui "${configureScriptPath}" --render-queue "${args.address}" ${dlExtraCommands.join(' ')} 2>&1`,
        `Remove-Item -Path "${configureScriptPath}"`,
      );
      if (args.restartLauncher ?? true) {
        host.userData.addCommands(
          'If (Get-Service "deadline10launcherservice" -ErrorAction SilentlyContinue) {',
          '  Restart-Service "deadline10launcherservice"',
          '} Else {',
          '  & "$DEADLINE_PATH/deadlinelauncher.exe" -shutdownall 2>&1',
          '  & "$DEADLINE_PATH/deadlinelauncher.exe" -nogui 2>&1',
          '}',
        );
      }
    }
  }