R
Railway2mo 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
Percy2mo ago
Project ID: N/A
Mozzy
Mozzy2mo ago
N/A Is there any way to, during build time, add all the env vars from Railway into an .env file?
Brody
Brody2mo ago
railway run only runs the given command locally. can you explain the usecase please?
Mozzy
Mozzy2mo ago
Oh, I've just misunderstood the command then I thought it was actually running the script on the remote machine (Railway)
Brody
Brody2mo ago
nope, but to understand your needs, can you tell us why instead of that what?
Mozzy
Mozzy2mo 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
Brody2mo 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
Mozzy2mo ago
I use a set of scripts to actually deploy/update the slash commands
No description
Brody
Brody2mo ago
I've never done discord bot development, but that feels a little unconventional?
Mozzy
Mozzy2mo 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
Brody2mo ago
and you can't run these commands locally? do they modify the filesystem?
Mozzy
Mozzy2mo ago
If you mean the slash commands, they are used here in the Discord client
Brody
Brody2mo ago
I mean those scripts
Mozzy
Mozzy2mo ago
They don't modify any files. And now I know that I can run them locally with the Railway vars
Brody
Brody2mo ago
yeah problem solved?
Want results from more Discord servers?
Add your server