4

I'm trying to create a task in some testing task group (for the CI) which will execute a server (That will run in the background) and continue to the next task.
But what actually happens, is that it just gets stuck in the "run server" task.

These are the variations that I tried to start my server in the background -

1. bash -c "python3 $(Build.Repository.LocalPath)/apache_deployment/run_server.py & >/dev/null  2>&1" & >/dev/null  2>&1

2. python3 $(Build.Repository.LocalPath)/apache_deployment/run_server.py & /dev/null  2>&1 &

3. python3 $(Build.Repository.LocalPath)/apache_deployment/run_server.py & disown

How can this problem be solved?

Drxxd
  • 1,860
  • 14
  • 34

1 Answers1

0

Putting in the background comes at the end of line. You are apparently trusting this code very much, with sending all its output straight to the sink.

python3 $(Build.Repository.LocalPath)/apache_deployment/run_server.py >/dev/null 2>&1 &

If your script is executable and contains the correct shebang, this should be enough:

$(Build.Repository.LocalPath)/apache_deployment/run_server.py >/dev/null 2>&1 &
SzG
  • 12,333
  • 4
  • 28
  • 41
  • Does it work in the foreground? Does it print something if you stop sending all its output to `/dev/null`? And BTW, what is `Build.Repository.Localpath`? Is it a program? – SzG Aug 20 '18 at 08:04
  • When I send it to /dev/null, it prints "Waiting for console output".. "Build.Repository.Localpath" is some vsts variable which points to the path of the local repository – Drxxd Aug 20 '18 at 08:23
  • Go step by step. No background, no /dev/null. `Build.Repository.Localpath` is a variable in what language? Because it's definitely not a shall variable, because they can't contain dots. And you are using it as a program with `$()`. If you didn't send everything to `/dev/null`, you'd probably see the error message `Build.Repository.Localpath: command not found`. – SzG Aug 20 '18 at 08:30
  • It seems that the problem was solved using the following command: `bash -c "python3 $(Build.Repository.LocalPath)/ApacheDeplyoment/apache_deployment/run_server.py -re_deploy >/dev/null 2>&1 &"`... The problem was really with the "background" character – Drxxd Aug 20 '18 at 12:15