As part of one of our builds we require a X server running. I'm trying to start Xvfb however when I'm adding this to job as a command or script it hangs and waits for Xvbf to finish instead of going onto the next job in the stage.

      How would I be able to start Xvbf in the background and let the Job continue?

      I've tried using &, && in a script. When using it as a command I can not as this is not a valid argument to Xvfb. Am I missing something? Is this possible?

            [BAM-11488] Starting a command in the background

            Ian Norton added a comment -

            Hi, We are still seeing this one.

            Ian Norton added a comment - Hi, We are still seeing this one.

            Ian Norton added a comment -

            Hello, I have another variation of this problem, I have a number of `pytest` tests, one of them will restart one of the system services (init scripts) on our test machines, when this test happens pytest and the parent bamboo bash script exit correctly but bamboo will wait until the system service that was restarted is terminated.

            The service in question used the common `nohup` pattern and works correctly on may other CI systems and OSs

            I've been able to condense the bug down to a single shell script example:

            #!/bin/bash
            set -e
            cat > sleep.sh << EOF
            echo starting
            nohup /bin/sleep 500 </dev/null>/dev/null 2>&1 &
            echo detached
            EOF
            
            cat > check.py << EOF
            #!/usr/bin/python
            """
            Test bamboo job termination. 
            """
            import subprocess
            
            def setup_module():
                print subprocess.check_output("/bin/sh", "sleep.sh"])
            
            def test_foo():
                print "hello"
            
            EOF
            
            python -m py.test check.py
            ps -ef

            This should exit with success after about 5 seconds but will wait the full 500 seconds until the sleep executed by nohup has ended.

            The problem does seem related in some way to STDIO file descriptors because if the subprocess.check_output() call is changed to subprocess.check_call() then bamboo does not block.
             

            Ian Norton added a comment - Hello, I have another variation of this problem, I have a number of `pytest` tests, one of them will restart one of the system services (init scripts) on our test machines, when this test happens pytest and the parent bamboo bash script exit correctly but bamboo will wait until the system service that was restarted is terminated. The service in question used the common `nohup` pattern and works correctly on may other CI systems and OSs I've been able to condense the bug down to a single shell script example: #!/bin/bash set -e cat > sleep.sh << EOF echo starting nohup /bin/sleep 500 </dev/ null >/dev/ null 2>&1 & echo detached EOF cat > check.py << EOF #!/usr/bin/python """ Test bamboo job termination. """ import subprocess def setup_module(): print subprocess.check_output( "/bin/sh" , "sleep.sh" ]) def test_foo(): print "hello" EOF python -m py.test check.py ps -ef This should exit with success after about 5 seconds but will wait the full 500 seconds until the sleep executed by nohup has ended. The problem does seem related in some way to STDIO file descriptors because if the subprocess.check_output() call is changed to subprocess.check_call() then bamboo does not block.  

            For Windows this issue can be solved with Groovy script. Groovy can execute an external program as an process:

            "/bin/application.exe".execute()

            And then check that application is running:

            println "tasklist /fi \"imagename eq application.exe\"".execute().text

             

            Alexander Ostapenko added a comment - For Windows this issue can be solved with Groovy script. Groovy can execute an external program as an process: "/bin/application.exe" .execute() And then check that application is running: println "tasklist /fi \" imagename eq application.exe\"".execute().text  

            This can be achieved e.g. via

            /bin/bash -c 'sleep 60  > /dev/null 2>&1 &'
            

            NOTE: This is a severe security issue. A detached process can spy on subsequently executing plans, potentially obtaining on confidential source code, passwords exposed in commands, etc.

            Johannes A added a comment - This can be achieved e.g. via /bin/bash -c 'sleep 60 > /dev/ null 2>&1 &' NOTE: This is a severe security issue. A detached process can spy on subsequently executing plans, potentially obtaining on confidential source code, passwords exposed in commands, etc.

            We have a requirement for this as well on windows. Any word on a time frame for a solution?

            Brad Riching added a comment - We have a requirement for this as well on windows. Any word on a time frame for a solution?

            I also have this requirement from a windows perspective and have found no solutions so far.

            Guyverthree added a comment - I also have this requirement from a windows perspective and have found no solutions so far.

            I have the same requirement on windows, but can not get this working.

            rutger schaafsma added a comment - I have the same requirement on windows, but can not get this working.

            PiotrA added a comment -

            Weird. Following task/script configuration is working for me, that is: Bamboo executes the script content in the background and finishes the Job meanwhile.

            Example I've used:

            Script body: (using Script Task)

            nohup /home/pstefaniak/sleep-10-minutes.sh > /home/pstefaniak/sleep.out 2> /home/pstefaniak/sleep.err < /dev/null &
            

            script:
            /home/pstefaniak/sleep-10-minutes.sh

            #!/bin/sh
            sleep 10m
            

            What shall we do now? Maybe you should open Support Request via http://support.atlassian.com ? That way an Atlassian support engineer could assist you...

            PiotrA added a comment - Weird. Following task/script configuration is working for me, that is: Bamboo executes the script content in the background and finishes the Job meanwhile. Example I've used: Script body: (using Script Task) nohup /home/pstefaniak/sleep-10-minutes.sh > /home/pstefaniak/sleep.out 2> /home/pstefaniak/sleep.err < /dev/null & script: /home/pstefaniak/sleep-10-minutes.sh #!/bin/sh sleep 10m What shall we do now? Maybe you should open Support Request via http://support.atlassian.com ? That way an Atlassian support engineer could assist you...

            Thanks for the sugguestion of using nohup. However this still did not produce the desired result of going on to the next stage.

            From my testing it appears that Bamboo is kicking the command or script off with an initial "sh" process and all scripts or commands there after are childs. The commands we tell to go to the background probably go to the background however Bamboo is waiting for the initial sh process to return. My guess is we need a way to send this sh command to the background.

            Please give a test to a solution you think will work and let me know what you think.

            Ryan Nelson added a comment - Thanks for the sugguestion of using nohup. However this still did not produce the desired result of going on to the next stage. From my testing it appears that Bamboo is kicking the command or script off with an initial "sh" process and all scripts or commands there after are childs. The commands we tell to go to the background probably go to the background however Bamboo is waiting for the initial sh process to return. My guess is we need a way to send this sh command to the background. Please give a test to a solution you think will work and let me know what you think.

            PiotrA added a comment -

            Ryan,

            You might be able to background the process (I'm not 100% sure as I didn't test it by myself) if you redirect the output streams and use nohup. e.g

            nohup /tmp/boo.sh > foo.out 2> foo.err < /dev/null &
            

            Could you please try using that in your script task?

            regards,
            PS

            PiotrA added a comment - Ryan, You might be able to background the process (I'm not 100% sure as I didn't test it by myself) if you redirect the output streams and use nohup. e.g nohup /tmp/boo.sh > foo.out 2> foo.err < /dev/ null & Could you please try using that in your script task? regards, PS

              Unassigned Unassigned
              afd4bb9faeed Ryan Nelson
              Affected customers:
              8 This affects my team
              Watchers:
              12 Start watching this issue

                Created:
                Updated:
                Resolved: