coder_agent shutdown / coder_script run_on_stop not working

Hi, I'm creating a set of script to run on start and stop. Start scripts run as expected, but run_on_stop scripts (or shutdown) not executing, there is my code
resource "coder_script" "manage_account" {
...
run_on_stop = true
run_on_start = true
script = templatefile("${path.module}/templates/manage_account.tpl", {
...
})
log_path = "/full_home/tmp/manage_account_${data.coder_workspace.me.transition}.log"
}
resource "coder_script" "manage_account" {
...
run_on_stop = true
run_on_start = true
script = templatefile("${path.module}/templates/manage_account.tpl", {
...
})
log_path = "/full_home/tmp/manage_account_${data.coder_workspace.me.transition}.log"
}
I found the /full_home/tmp/manage_account_start.log, but not stop log, and stop action is not executed. Any idea with this? Thanks!
Solution:
https://github.com/coder/envbox/pull/134 Shutdown scripts were indeed broken, they should be fixed with this PR...
Jump to solution
10 Replies
Codercord
Codercord4mo ago
<#1329720357472567296>
Category
Help needed
Product
Coder (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
Phorcys
Phorcys4mo ago
hey, is /full_home/tmp a persistent folder?
Martí
MartíOP3mo ago
sure! i can persist any files on this directory
Phorcys
Phorcys3mo ago
that's not what I meant to me, it seems like you are runnig a script on stop, then storing a log file, then you expect to see that log file once the workspace starts up but since the workspace has been destroyed, that is not going to be the case
jamesoldstob
jamesoldstob3mo ago
I'm seeing this issue as well. I have a shutdown_script specified in my coder_agent resource
shutdown_script = "echo shutdown script ran on $(date) > /home/${local.linux_user}/shutdown.log"
shutdown_script = "echo shutdown script ran on $(date) > /home/${local.linux_user}/shutdown.log"
The script doesn't seem to run, there is no shutdown.log present on reboot. Coder server ver v2.18.3 Using these providers for the workspace
terraform {
required_providers {
coder = {
source = "coder/coder"
version = "2.1.2"
}
google = {
source = "hashicorp/google"
version = "6.18.1"
}
...
terraform {
required_providers {
coder = {
source = "coder/coder"
version = "2.1.2"
}
google = {
source = "hashicorp/google"
version = "6.18.1"
}
...
And yes that is a persistent directory. I can write to it, restart, and expect my files to still be there As far as I know this was working before upgrading to 2.18.3 (from 2.15.1)
Atif
Atif3mo ago
Hi @jamesoldstob could you open a GtHub issue? Also include an example that you belive was working on 2.15.1 Thanks
Solution
zounce
zounce3w ago
https://github.com/coder/envbox/pull/134 Shutdown scripts were indeed broken, they should be fixed with this PR
zounce
zounce3w ago
no envbox release just yet
JD
JD3w ago
I can confirm that it's fixed with that PR 🤘
Codercord
Codercord2w ago
@Phorcys closed the thread.

Did you find this page helpful?