Closed dezren39 closed 8 months ago
ok right now i'm launching background right before start.sh
./provider/background.sh &
./provider/start.sh
there's probably a better way
are you sure about this? i think i am doing something like this on https://connect4.bashsta.cc/
i remember this working fine, but i could totally be wrong
could you tell me more about what you're trying to do?
yeah i had something exactly like that, but it held the connection open indefinitely until the background process closed. the flow is something like
@dezren39 some questions
i'll try to see if i can repro
this is my laptop where i am hosting this, which is WSL. it could be WSL related, eventually it will be running in a vm somewhere and i can confirm if it reproduces elsewhere.
user@laptop-framework:~$ bash --version
bash --version
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
user@laptop-framework:~$ cat /etc/os-release
cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.4 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
i just made this change locally and it now times out before sending the result
# cat << EOF > "$BACKGROUND_JOB_PATH"
# #!/usr/bin/env bash
# CHARM_DIR="$CHARM_DIR" $IDENTITY_DIR/identity charm link -d -o "$LINK_CODE_PATH" -k "${FORM_DATA[$key]}"
# EOF
CHARM_DIR="$CHARM_DIR" $IDENTITY_DIR/identity charm link -d -o "$LINK_CODE_PATH" -k "${FORM_DATA[$key]}" &
the binary doesn't read from stdin, it takes some args and then it outputs a file i look for and then eventually has an exit code based on if link was established.
i also tried using nohup/disown a little bit but i couldn't figure out a way to get them to work.
yeah ok, i am able to repro this too 😢
i will look into a solution
okay i think i'm starting to understand this
i think you need to redirect stdin
, stdout
, and stderr
on the background process, otherwise it will block the exit
i created an example project: https://github.com/cgsdev0/bash-stack/tree/main/examples/bg-task
notable files:
i am using SSE here because it's currently the only mechanism for sending asynchronous data back to the user
ok i think i kind of understand, i can try and copy that example at least and see if it works for me, thank you
it works!!! thank you!
if you run something like this
there is no way to send sleep to background in bash. it will always wait.
this affects pages here, because pages are injected using $().
you can't send a response back, while also launching a process per-response that persists any length after the response.
i will solve this with a special file dir and a process launched ahead of time looking for files dropped off to launch, removing the long-running process from the command substitution. i am opening this because others may also encounter this. feel free to close. :-)
thanks for the fun project, very convenient except for all the bash.