Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running 'background' task hangs #162

Closed
orthomind opened this issue Jan 18, 2019 · 7 comments
Closed

Running 'background' task hangs #162

orthomind opened this issue Jan 18, 2019 · 7 comments

Comments

@orthomind
Copy link

Hi,

I'm trying to create a task to start up a cockroachdb instance. One of the commands I use is the actual running of the instance:

cockroach start --background --host=localhost --http-host=localhost --certs-dir="$(echo ~)/.cmswww/data/testnet3/cockroachdb"

The --background flag is described as follows:

      --background                                  
        Start the server in the background. This is similar to appending "&"
        to the command line, but when the server is started with --background,
        control is not returned to the shell until the server is ready to
        accept requests.

Unfortunately, when I use this flag, Task does not seem to progress beyond this step. It's as though the cockroachdb instance never returns to shell. However, when I run this command in the shell manually, it works as expected.

Do you know why this may not work when I use it in task, while it works as expected outside of that?

Thanks!

@andreynering andreynering added the type: bug Something not working as intended. label Jan 19, 2019
@andreynering
Copy link
Member

Hi @orthomind,

Maybe --background messes with more obscure OS stuff, and something in between isn't cooperating.

This can either be a bug on CockroachDB, on mvdan/sh or Task itself.

Can you please try running this command on Make and Gosh? You'd be helping me debug this issue.

Also, what's your Task version and OS?

@andreynering
Copy link
Member

Ping @orthomind

@orthomind
Copy link
Author

Hi, sorry, I will try to check these things out for you within a week or so.

@weeping-somnambulist
Copy link

Hey @orthomind I'm attempting to assist @andreynering in clearing out some bugs. Is this still and issue with the current version? If so, can you include the Taskfile.yml that you're using, as well as the operating system that you're on so I can attempt to replicate it?

If not, can we close this issue?

@andreynering
Copy link
Member

Closing for lack of feedback.

If you still have updates, feel free to comment and we may reopen the issue.

@cr1cr1
Copy link

cr1cr1 commented Jan 2, 2024

I'm having this issue.

task --version
Task version: v3.33.1 (h1:JJSRANHH7RQrr5Z2CTvSnTH7iWlfBlKV2W2O0JiZoLk=)

Trying to start a server process in background.

  1. cat bin/nats-server.sh
#!/bin/bash
nats-server --log bin/nats-server.log& echo "PID $!"
  1. bin/nats-server.sh
    PID 3439
ps -fp 3439
UID     PID    PPID  TTY        STIME COMMAND
cri    3439       1 cons1    11:35:33 /c/tools/scoop/shims/nats-server
  1. Windows: gosh -c bin/nats-server.sh or gosh -c bash -c bin/nats-server.sh
    fork/exec x:\bin\nats-server.sh: %1 is not a valid Win32 application.

  2. Linux: gosh -c bin/nats-server.sh
    PID 7871

ps -fp 7871
UID          PID    PPID  C STIME TTY          TIME CMD
root        7871     353  0 11:49 pts/0    00:00:00 nats-server --log bin/nats-server.log
  1. Windows & Linux: gosh -c 'bash -c bin/nats-server.sh' (single quotes around the command)
    PID 3491
ps -fp 3491
UID     PID    PPID  TTY        STIME COMMAND
cri    3491       1 cons1    11:38:56 /c/tools/scoop/shims/nats-server
  1. Taskfile:
  run_nats_server:
    deps:
      - install_nats
      - install_nats_server
    status:
      - nats server check connection
    cmds:
      - echo "Starting nats-server"
      - |
        PATH="bin{{.PD}}$PATH"
        echo '#!/bin/bash
        nats-server --log bin/nats-server.log& echo "PID $!"' > bin/nats-server.sh
        chmod +x bin/nats-server.sh
        bash -c 'bin/nats-server.sh'
task run_nats_server
[run_nats_server] Starting nats-server
[run_nats_server] PID 3525

hangs both in Windows and Linux

@cr1cr1
Copy link

cr1cr1 commented Jan 2, 2024

Apparently, running the task cmd in background as well as the underlying bash one, with a sleep after, works:

    cmds:
      - echo "Starting nats-server"
      - |
        PATH="bin{{.PD}}$PATH"
        bash -c 'nats-server --log bin/nats-server.log& echo "PID $!"'& sleep 1
task run_nats_server
[run_nats_server] Starting nats-server
[run_nats_server] PID 4079

ps -fp 4079
UID     PID    PPID  TTY        STIME COMMAND
cri    4079       1 cons1    12:19:09 /x/path/bin/nats-server

@pd93 pd93 removed the type: bug Something not working as intended. label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants