Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-28811

Can't start background process during init of new worker?

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • ec2-plugin
    • Jenkins: 1.596.3
      Amazon EC2 plugin: 1.28
      Amazon Linux

      I'm utilizing the EC2 plugin to spin up Jenkins worker slaves on-demand. During the start-up of each worker, I want to download and start a selenium server.

      After downloading the selenium server jar via curl, I've tried starting selenium via the Init Script.

      Both:
      screen -d -m -L -S selenium java -jar /tmp/selenium-server-standalone.jar

      And:
      nohup java -jar /tmp/selenium-server-standalone.jar &

      Fail to start selenium. I've done a little digging, and in each case those commands exit with a status of 0, but it seems like nothing happens.

      As a workaround, I'm using a cronjob to ensure selenium is running via screen. It is pretty hacky. I'd love to start a background process via the Init Script.

      EDIT: I've added a screenshot of the work config, as well as full text of the Init Script.

          [JENKINS-28811] Can't start background process during init of new worker?

          Vincent Rivellino created issue -
          Vincent Rivellino made changes -
          Description Original: I'm utilizing the EC2 plugin to spin up Jenkins worker slaves on-demand. During the start-up of each worker, I want to download and start a selenium server.

          After downloading the selenium server jar via curl, I've tried starting selenium via the Init Script.

          Both:
          {{screen -d -m -L -S selenium java -jar /tmp/selenium-server-standalone.jar}}

          And:
          {{nohup java -jar /tmp/selenium-server-standalone.jar &}}

          Fail to start selenium. I've done a little digging, and in each case those commands exit with a status of 0, but it seems like nothing happens.

          As a workaround, I'm using a cronjob to ensure selenium is running via screen:

          {{curl -o /tmp/selenium-server-standalone.jar http://selenium-release.storage.googleapis.com/2.46/selenium-server-standalone-2.46.0.jar

          cat > /etc/cron.d/selenium-hack << _END_
          * * * * * ec2-user test -n "\`ls -1 /var/run/screen/S-ec2-user\`" || screen -d -m -L -S selenium java -jar /tmp/selenium-server-standalone.jar
          _END_

          sleep 60}}

          This is pretty hacky. I'd love to start a background process via the Init Script.
          New: I'm utilizing the EC2 plugin to spin up Jenkins worker slaves on-demand. During the start-up of each worker, I want to download and start a selenium server.

          After downloading the selenium server jar via curl, I've tried starting selenium via the Init Script.

          Both:
          {{screen -d -m -L -S selenium java -jar /tmp/selenium-server-standalone.jar}}

          And:
          {{nohup java -jar /tmp/selenium-server-standalone.jar &}}

          Fail to start selenium. I've done a little digging, and in each case those commands exit with a status of 0, but it seems like nothing happens.

          As a workaround, I'm using a cronjob to ensure selenium is running via screen:

          {quote}curl -o /tmp/selenium-server-standalone.jar http://selenium-release.storage.googleapis.com/2.46/selenium-server-standalone-2.46.0.jar

          cat > /etc/cron.d/selenium-hack << _END_
          * * * * * ec2-user test -n "\`ls -1 /var/run/screen/S-ec2-user\`" || screen -d -m -L -S selenium java -jar /tmp/selenium-server-standalone.jar
          _END_

          sleep 60{quote}

          This is pretty hacky. I'd love to start a background process via the Init Script.
          Vincent Rivellino made changes -
          Attachment New: slave-init.txt [ 29924 ]
          Attachment New: jenkins-slave-config.png [ 29925 ]
          Description Original: I'm utilizing the EC2 plugin to spin up Jenkins worker slaves on-demand. During the start-up of each worker, I want to download and start a selenium server.

          After downloading the selenium server jar via curl, I've tried starting selenium via the Init Script.

          Both:
          {{screen -d -m -L -S selenium java -jar /tmp/selenium-server-standalone.jar}}

          And:
          {{nohup java -jar /tmp/selenium-server-standalone.jar &}}

          Fail to start selenium. I've done a little digging, and in each case those commands exit with a status of 0, but it seems like nothing happens.

          As a workaround, I'm using a cronjob to ensure selenium is running via screen:

          {quote}curl -o /tmp/selenium-server-standalone.jar http://selenium-release.storage.googleapis.com/2.46/selenium-server-standalone-2.46.0.jar

          cat > /etc/cron.d/selenium-hack << _END_
          * * * * * ec2-user test -n "\`ls -1 /var/run/screen/S-ec2-user\`" || screen -d -m -L -S selenium java -jar /tmp/selenium-server-standalone.jar
          _END_

          sleep 60{quote}

          This is pretty hacky. I'd love to start a background process via the Init Script.
          New: I'm utilizing the EC2 plugin to spin up Jenkins worker slaves on-demand. During the start-up of each worker, I want to download and start a selenium server.

          After downloading the selenium server jar via curl, I've tried starting selenium via the Init Script.

          Both:
          {{screen -d -m -L -S selenium java -jar /tmp/selenium-server-standalone.jar}}

          And:
          {{nohup java -jar /tmp/selenium-server-standalone.jar &}}

          Fail to start selenium. I've done a little digging, and in each case those commands exit with a status of 0, but it seems like nothing happens.

          As a workaround, I'm using a cronjob to ensure selenium is running via screen. It is pretty hacky. I'd love to start a background process via the Init Script.

          EDIT: I've added a screenshot of the work config, as well as full text of the Init Script.

          Francis Upton added a comment -

          The init script is run only on the the first startup of the instance to initialize it. There is nothing in the ec2 plugin the supported initialization of an existing instance when it is started.

          Francis Upton added a comment - The init script is run only on the the first startup of the instance to initialize it. There is nothing in the ec2 plugin the supported initialization of an existing instance when it is started.
          Francis Upton made changes -
          Resolution New: Not A Defect [ 7 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]
          R. Tyler Croy made changes -
          Workflow Original: JNJira [ 163671 ] New: JNJira + In-Review [ 197275 ]

            francisu Francis Upton
            vrivellino Vincent Rivellino
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: