Skip to content

chore(examples): Add login_before_ready and startup_script_timeout #5880

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

Merged
merged 13 commits into from
Jan 27, 2023

Conversation

mafredri
Copy link
Member

Refs: #5749
Depends on: #5749

  • chore(examples): Update all coder providers to v0.6.9
  • chore(examples): Add delay_login_until_ready and startup_script_timeout

@mafredri mafredri self-assigned this Jan 26, 2023
# install and start code-server
curl -fsSL https://code-server.dev/install.sh | sh -s -- --version 4.8.3 | tee code-server-install.log
Copy link
Member Author

@mafredri mafredri Jan 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed tee here because install log is already available in agent startup script log (and before this refactor, this file was overwritten by the following tee.

curl -fsSL https://code-server.dev/install.sh | sh -s -- --version 4.8.3 | tee code-server-install.log
code-server --auth none --port 13337 | tee code-server-install.log &
curl -fsSL https://code-server.dev/install.sh | sh -s -- --version 4.8.3
code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 &
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redirecting both stdout and stderr for log. Could also use 2>&1 | tee /tmp/code-server.log if preferable.

os = "linux"
dir = "/home/coder"
startup_script = <<EOT
#!/bin/bash
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed all shebangs because I didn't want users to get the wrong idea that we obey the shebang. In unix, we should run script via /bin/bash if it has this header, but we don't. Likewise for #!/bin/sh we should use /bin/sh, but we don't.

@mafredri mafredri marked this pull request as ready for review January 26, 2023 19:49
@mafredri mafredri requested review from bpmct and kylecarbs January 26, 2023 19:50
Copy link
Member

@bpmct bpmct left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to test this against dev.coder.com before we merge? I was under the impression that background jobs would be killed when the parent process is, but I don't understand the inner workings of how Coder runs the startup script so I might be missing something.

@mafredri
Copy link
Member Author

Is it possible to test this against dev.coder.com before we merge? I was under the impression that background jobs would be killed when the parent process is, but I don't understand the inner workings of how Coder runs the startup script.

@bpmct I could make the dogfood changes a separate PR, but we've already been using this pattern for a long time in the dev.coder.com default dogfood template. It launches code-server via & and the startup script will end.

I imagine some version of /bin/sh may behave such that it will not exit until the child process exits, but most of the time this is not the case. A simple test:

/bin/bash -c 'sleep 10 &'; sleep 1; ps aux | grep sleep\ 10
/bin/sh -c 'sleep 10 &'; sleep 1; ps aux | grep sleep\ 10

This works fine and the sleep command keeps running. I've also tested all the docker templates in my home deployment and they seem to behave correctly.

@mafredri mafredri changed the title chore(examples): Add delay_login_until_ready and startup_script_timeout chore(examples): Add login_before_ready and startup_script_timeout Jan 27, 2023
@mafredri mafredri enabled auto-merge (squash) January 27, 2023 20:41
@mafredri mafredri merged commit a121201 into main Jan 27, 2023
@mafredri mafredri deleted the mafredri/chore-example-delay-login branch January 27, 2023 21:01
@github-actions github-actions bot locked and limited conversation to collaborators Jan 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants