R
Railway14mo ago
drdrigg

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
Percy
Percy14mo ago
Project ID: 988851b6-78d5-44de-a73d-3e5b6468c8bf
Brody
Brody14mo ago
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)
drdrigg
drdriggOP14mo ago
ok interesting! But how can I run rake tasks?
Brody
Brody14mo ago
what do these tasks do? if they just interact with the database then you can run them locally
drdrigg
drdriggOP14mo ago
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.
Brody
Brody14mo ago
yeah that sounds like just interacting with the database
drdrigg
drdriggOP14mo ago
Yes basically, but using a rake task
Brody
Brody14mo ago
you should have no problem using the rails console from within railway shell
drdrigg
drdriggOP14mo ago
So how do I access the railway shell?
Brody
Brody14mo ago
oh mb, here's the docs for the cli https://docs.railway.app/develop/cli
drdrigg
drdriggOP14mo ago
railway shell No service linked, not entering shell. I first ran railway link
Brody
Brody14mo ago
run railway service
drdrigg
drdriggOP14mo ago
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.
Brody
Brody14mo ago
what's N/A supposed to mean
drdrigg
drdriggOP14mo ago
No idea 🙂 I tried both the Rails service and the Postgres service Both have the same error
Brody
Brody14mo ago
screenshot please
drdrigg
drdriggOP14mo ago
No description
Brody
Brody14mo ago
what OS and terminal is this?
drdrigg
drdriggOP14mo ago
MacOs Default terminal MacOS 13.3.1 (22E261) Ventura
Brody
Brody14mo ago
going to tag in @alex for this, could you try to repro this when you have the time?
drdrigg
drdriggOP14mo ago
oki Thanks
alex
alex14mo ago
No pgsql installed on his computer Weird bug being thrown by the cli tho
Brody
Brody14mo ago
they only ran railway shellthough, what does pgsql have to do with that?
alex
alex14mo ago
Maybe I’ll peep the cli code later Rn I’m sick Like hella sick
Brody
Brody14mo ago
get well soon <$
alex
alex14mo ago
Like two boxes of tissues nod
macwilko
macwilko14mo ago
idk if this is helpful @drdrigg but I use the Rails console like this:
railway run env SSL_CA_PATH="/etc/ssl/cert.pem" rails c
railway run env SSL_CA_PATH="/etc/ssl/cert.pem" rails c
note, all this does is run yor rails app with env variables pulled from your Railway instance
drdrigg
drdriggOP14mo ago
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.
macwilko
macwilko14mo ago
@drdrigg hmm, I do have slow response times, but I haven't determined if that's Railway or my bad coding.
drdrigg
drdriggOP14mo ago
Do you also use Postgres?
macwilko
macwilko14mo ago
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
drdrigg
drdriggOP14mo ago
My main rails server, postgres and redis is located in Amsterdam, Europe.
macwilko
macwilko14mo ago
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?
drdrigg
drdriggOP14mo ago
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.
macwilko
macwilko14mo ago
yeah... man I should probably do some tests to compare myself which VPS are you using have you tried Fly.io ?
drdrigg
drdriggOP14mo ago
I am using Vultr.com. I tried fly.io but Railway is vastly superior
macwilko
macwilko14mo ago
Right why do you want to move from Vultr to Railway? curious
drdrigg
drdriggOP14mo ago
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)
macwilko
macwilko14mo ago
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.
drdrigg
drdriggOP14mo ago
Also I could get $250 down to like $25 which is quite nice to 🙂
macwilko
macwilko14mo ago
but if you're scaling up, and need performance, it might not be the fastest
drdrigg
drdriggOP14mo ago
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).
macwilko
macwilko14mo ago
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.
macwilko
macwilko14mo ago
macwilko
macwilko14mo ago
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.
drdrigg
drdriggOP14mo ago
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
macwilko
macwilko14mo ago
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 👌⭐️
macwilko
macwilko14mo ago
No description
macwilko
macwilko14mo ago
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?
drdrigg
drdriggOP14mo ago
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.
macwilko
macwilko14mo ago
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?
Want results from more Discord servers?
Add your server