Specifying command for running coder-based deployment

Hi there. I'm going to create python-based service for kubernetes using coder. I created template with deployment and specified the following parameters: resource "coder_agent" "main" { ... startup_script = "pip install requests" ... } resource "kubernetes_deployment" "main" { ... args = ["sh", "-c", "bash ${coder_agent.main.init_script}"] ... } I need some place to specify command for run my code. For example python web-server.py What is the best place for it?
7 Replies
Codercord
Codercord4w ago
<#1299045725564567614>
Category
Help needed
Product
Coder OSS (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
Atif
Atif4w ago
You can do it within the startup_script
Phorcys
Phorcys4w ago
^ use either the startup_script or a coder_script resource and for example you can do python <folder>/web-server.py >/tmp/backend.log 2>&1 &
Sergio
SergioOP4w ago
I can't use startup_script for continuously running code because startup_script shouldn't run forever and should not forever send stdout to coder UI. This works, but in this case I will lose my output. I need to collect my stdout/stderr with standard tools (loki etc.)
Phorcys
Phorcys4w ago
well if you're doing that in the startup_script then the output is kept in Coder but anyways you can also just read the log file if that were to fail you
Sergio
SergioOP4w ago
If I'll do this in the startup_script - coder will show the error message bacause regarding startup_script didn't stop and will show another error after 1MB logs. So, no standard way to run my code keeping regular behavior of stdin/stderr?
Phorcys
Phorcys4w ago
you'll want to do fork the process with the & symbol at the end so that it's still logging but not waiting for it
Want results from more Discord servers?
Add your server