Access rails console and run rake tasks?
Is it possible to run rake tasks on the server here at Railway? And even perhaps possible to access the rails console on the server?
Project ID: 988851b6-78d5-44de-a73d-3e5b6468c8bf
51 Replies
Project ID:
988851b6-78d5-44de-a73d-3e5b6468c8bf
it's not, but if you're just using it to interact with your database, you can run it within the railway shell (local shell with railway environment variables)
ok interesting! But how can I run rake tasks?
what do these tasks do? if they just interact with the database then you can run them locally
Basically different maintainance tasks. Like checking all accounts that are too old and then remove them. Or changing a lot of records at once. Things like that.
yeah that sounds like just interacting with the database
Yes basically, but using a rake task
you should have no problem using the rails console from within railway shell
So how do I access the railway shell?
oh mb, here's the docs for the cli https://docs.railway.app/develop/cli
railway shell
No service linked, not entering shell.
I first ran railway link
run
railway service
And selected a team and a project
Entering subshell with Railway variables available. Type 'exit' to exit.
N/A: version "N/A -> N/A" is not yet installed.
You need to run "nvm install N/A" to install it before using it.
what's N/A supposed to mean
No idea 🙂
I tried both the Rails service and the Postgres service
Both have the same error
screenshot please
what OS and terminal is this?
MacOs
Default terminal
MacOS 13.3.1 (22E261) Ventura
going to tag in @alex for this, could you try to repro this when you have the time?
oki
Thanks
No pgsql installed on his computer
Weird bug being thrown by the cli tho
they only ran
railway shell
though, what does pgsql have to do with that?Maybe I’ll peep the cli code later
Rn I’m sick
Like hella sick
get well soon <$
Like two boxes of tissues
idk if this is helpful @drdrigg but I use the Rails console like this:
note, all this does is run yor rails app with env variables pulled from your Railway instance
Thank you! BTW, have you experienced any performance issues with you rails app on Railway? I get 480 ms response time on average on Railway but for the same request/endpoint on a regular VPS only 70 ms. Both Railway and VPS is in Amsterdam.
@drdrigg hmm, I do have slow response times, but I haven't determined if that's Railway or my bad coding.
Do you also use Postgres?
MySQL
Where is your database located?
I believe by default Railway is us-west
if you can do any tests confirming slow speed on Railway, I'de like to know it
I just have some performance issues but mostly I figured it was due to N+1 queiries
My main rails server, postgres and redis is located in Amsterdam, Europe.
wow
so literally just running the rails app on Railway vs VPS, you're getting that much additional latancy
is it a Dockerfile you're running?
Yes, I am using a Dockerfile and yes, same code and same user and same data.
Which is frustrating because I really want to use Railway for my rails app.
yeah...
man I should probably do some tests to compare myself
which VPS are you using
have you tried Fly.io ?
I am using Vultr.com. I tried fly.io but Railway is vastly superior
Right
why do you want to move from Vultr to Railway? curious
I love Railways interface, innovations and the overall flow of everything
How all is kept together. I am using Cloud66.com to handle the servers (I know very little about servers)
gotcha... i mean, railway for me is super easy to run and administer as an individual.
So perhaps it's not the fastest solution, but as a 1 man startup, I run everything here and it works fine.
Also I could get $250 down to like $25 which is quite nice to 🙂
but if you're scaling up, and need performance, it might not be the fastest
Its fast for my ExpressJS / NextJS project.
Rails is a bit legacy now (at least in the hosting world, very hard to find good hosting).
hmm, have you spoken to anyway at Railway about this? I have a call booked with Angelo tomorrow, I can bring it up
I am not an expert enough to know where the issue could be
you're on the Pro plan so I expect you can talk to the Railway engineers
here's my app
it's a Rails backend / graphql API
you can see loading a chat conversation is pretty slow
bare in mind, it's hosted in us-west, database is also in us-west. I am located in UK.
the data behind this app is as complex as any SaaS you'll find I imagine
i really would like it to be faster
but I don't have much resources to spend on optimising it just yet 😦 I have features needing to be built presently.
This is exactly what I am experincing. Very slow, even in Postman.
Great app BTW, looks very nice!
Have you tried moving the app to the EU cloud?
Its very simple now with the new location setting
I would, but all my customers are in the US
I’m hoping multi regional services are a thing soon, which sounds like it might be
If you can send anything to me at [email protected] I’ll bring it up on my call tomorrow with Angelo
I’m keen to have faster performance also
Thanks!! Rails isn’t dead yet 👌⭐️
My response time processing webhooks is pretty fast
But those don’t touch the database layer much
I wonder if it’s due to some slow connection between the database and the service
Have you tried testing using Railway Postgres?
I am only using Railway services, Rails app, Redis service template and Postgres service template. I also tried both connecting to database using "public" url and using "private" direct url. Same result.
ok good to know
have you got any tests / numbers to share at all?
since we're both running Rails apps, and both on Pro plan
maybe worth talking together to Railway team
also, can you try test hitting a route on the rails app that doesn't call out to your Database?