R
Railway11mo ago
Mattèo

How to execute command on a deployment ?

Hey ! I wanted to know how to execute a command on a deployed service, I have small script in my project to initialize an admin account, but this script needs to be executed with a started service. Is it possible to connect with SSH to an instance, or to execute a command after starts of a service ? Bye
5 Replies
Percy
Percy11mo ago
Project ID: N/A
Mattèo
Mattèo11mo ago
N/A
Brody
Brody10mo ago
no that's not possible, depending on how your app is setup you should be able to run the command locally through railway run for clarification, railway run runs the command locally but with the railway service variables available to the command it ran
Mattèo
Mattèo10mo ago
Okay thanks for you reply, Is there a workaround for executing a command on an instance? Lots of softwares use steps like this to migrate db, create admin user, etc...
Brody
Brody10mo ago
sorry I won't be advising on how to do something like that as it's anti-pattern and a lot of those commands can be run locally with the railway environment variables, and that's specifically why railway run exists, if you absolutely do need to run commands on your container, you'd likely want a vps