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