R
Railway4mo ago
Mozzy

Skill issue with `railway run`

Having a skill issue. I want to run a .js script remotely on Railway. railway run npm run script works, but this is a node command that uses --env-file, and the .env file is not present after building the app. Can I just run any remote file directly?
Solution:
and you can't run these commands locally? do they modify the filesystem?
Jump to solution
17 Replies
Percy
Percy4mo ago
Project ID: N/A
Mozzy
MozzyOP4mo ago
N/A Is there any way to, during build time, add all the env vars from Railway into an .env file?
Brody
Brody4mo ago
railway run only runs the given command locally. can you explain the usecase please?
Mozzy
MozzyOP4mo ago
Oh, I've just misunderstood the command then I thought it was actually running the script on the remote machine (Railway)
Brody
Brody4mo ago
nope, but to understand your needs, can you tell us why instead of that what?
Mozzy
MozzyOP4mo ago
Now that I understand that it simply grabs the env vars(?), it's all good. The use case is deploying slash commands of a Discord bot in the live environment
Brody
Brody4mo ago
yeah railway run grabs the environment variables set in the service variables and injects them into a temporary environment that the given command runs in. may I ask how railway run comes into play here? wouldn't you just make the necessary code changes to support slash commands and then push the changes to Github?
Mozzy
MozzyOP4mo ago
I use a set of scripts to actually deploy/update the slash commands
No description
Brody
Brody4mo ago
I've never done discord bot development, but that feels a little unconventional?
Mozzy
MozzyOP4mo ago
The alternative is to deploy commands on every start In my experience, Discord doesn't invalidate the old commands until one of them are used Which makes the first use return an error
Solution
Brody
Brody4mo ago
and you can't run these commands locally? do they modify the filesystem?
Mozzy
MozzyOP4mo ago
If you mean the slash commands, they are used here in the Discord client
Brody
Brody4mo ago
I mean those scripts
Mozzy
MozzyOP4mo ago
They don't modify any files. And now I know that I can run them locally with the Railway vars
Brody
Brody4mo ago
yeah problem solved?
Mozzy
MozzyOP4mo ago
Pretty much
Brody
Brody4mo ago
awesome
Want results from more Discord servers?
Add your server