Rails setup issue

Still trying to migrate over from Heroku. Server is up and running now, but when i access the webpage, i get a Railway "Application failed to respond" page. However, watching the logs, the server is responding and with no errors, so I'm really not sure what's going on. This is a Rails app. I do notice there does not seem to be any views being processed by the Controller, which is very odd; not something I've ever experienced before. Any thoughts? Also is there no way to ssh in to the Railway instance, (like heroku run console?). railway run rails console just seems to be my local machine 🤔 Project ID: dbb32a7b-e126-450a-89f1-55383bcf99b8
68 Replies
Percy
Percy2y ago
Project ID: dbb32a7b-e126-450a-89f1-55383bcf99b8
beninate
beninateOP2y ago
actually, i take that back, views are rendering. I have no idea what's going on then 🤔 Why would Railway be displaying an "Application failed to respond" page when the server is responding as expected? i think i need to set the PORT properly in the Procfile. Will touch back later
Adam
Adam2y ago
Don’t set it in the procfile, set it in your environment variables this docs page can help you out
beninate
beninateOP2y ago
Ok, i guess what confused me earlier in that article is that it says setting a PORT env variable is not recommended? In any case, i just set one to 3000, but now the server isn't responding to requests at all 🤔
[1] * Listening on http://0.0.0.0:3000
[1] Use Ctrl-C to stop
2023-07-09 21:28:31 +0000 HTTP parse error, malformed request: #<Puma::HttpParserError: Invalid HTTP format, parsing fails. Are you trying to open an SSL connection to a non-SSL Puma?>
[1] * Listening on http://0.0.0.0:3000
[1] Use Ctrl-C to stop
2023-07-09 21:28:31 +0000 HTTP parse error, malformed request: #<Puma::HttpParserError: Invalid HTTP format, parsing fails. Are you trying to open an SSL connection to a non-SSL Puma?>
im sure im just missing something stupid?
Adam
Adam2y ago
Pretty sure you should be listening on https, not http. Would be helpful to see your repo
Brody
Brody2y ago
http is the correct scheme to listen on
MantisInABox
MantisInABox2y ago
web: rake db:migrate && bin/rails server -b 0.0.0.0 -p ${PORT:-3000} try this for your Procfile
beninate
beninateOP2y ago
Ok, that’s what I was assuming initially; will try that in a bit thx same exact result. should i remove the PORT environment variable?
MantisInABox
MantisInABox2y ago
No, you need to be listening on the port environment variable since that is the traffic port provided by your container
beninate
beninateOP2y ago
hmm, any idea then? could it be my puma.rb? though im not sure that is even being used anymore with that Procfile tweak
MantisInABox
MantisInABox2y ago
Honestly, that was the extent of my knowledge with running rails on railway. I have not done rails dev in a few years. Are you able to share your repo?
beninate
beninateOP2y ago
unfortunately not the whole thing, no. but i could share specific bits
MantisInABox
MantisInABox2y ago
Fair enough Let me do some digging around and see if we can solve it for ya
beninate
beninateOP2y ago
bless 🙏
MantisInABox
MantisInABox2y ago
I’ll report back
beninate
beninateOP2y ago
unsolicited feedback, but i think this is one area where Railway is lagging behind a bit. Heroku has very clear and specific docs on how to specifically get Ruby on Rails up and running on their platform. Not finding much here on Railway; though i know they are adding things all the time.
MantisInABox
MantisInABox2y ago
The docs are open source, so when we find a solution, you can always contribute to them as well! See if you can match this template up with your current configuration the best you can. I have testing this in the past and know it works https://github.com/railwayapp-templates/ruby-rails
GitHub
GitHub - railwayapp-templates/ruby-rails
Contribute to railwayapp-templates/ruby-rails development by creating an account on GitHub.
MantisInABox
MantisInABox2y ago
Just as a starting point for further testing
beninate
beninateOP2y ago
nice! copy that, i'll run through that in a bit Ok, so I've ended up getting further along now, but the "solution" seemed to be disabling force_ssl in config/environments/staging.rb. But that's not good; we definitely want to force SSL, and that should be supported, no? Additionally, im now back to the server responded successfully to requests, yet im still getting the Railway "Application failed to respond" 😩
[1] * Listening on http://0.0.0.0:3000
[1] * Listening on http://0.0.0.0:3000
indeed listening on the right port...
MantisInABox
MantisInABox2y ago
You should not need to force ssl, as your container sits behind a reverse proxy that is already enforcing ssl connections
beninate
beninateOP2y ago
ok, good to know 👍 what in the heckin sorcery i just turned force_ssl back on just to check something and now the app is loading perfectly fine for the first time 😂
MantisInABox
MantisInABox2y ago
That is weird. Could have been that the rails server wasn’t rebooting properly
beninate
beninateOP2y ago
i dont even know what fixed it anymore 😆
MantisInABox
MantisInABox2y ago
Just remember, it’s not going to be 100% easy switch from platforms like Heroku. Heroku has buildpacks that are very specific build instructions. Here it’s nixpacks which are a bit more loose and can be configured to handle a variety of situations. You can also deploy a Dockerfile, so, if you have a working dockerfile for your project, you can deploy that as well
beninate
beninateOP2y ago
trying to get it up and running as vanilla as possible and just let Railway do its magic. So far, so good. but i still got a lot of stuff to work out. but at least we've finally got a working build is there really no way to ssh into a Railway instance (even like heroku run console)? that seems like a potential roadblock for us
MantisInABox
MantisInABox2y ago
There is not a way to ssh into the instance at this time, no
beninate
beninateOP2y ago
dang.... any idea if there's plans to add?
MantisInABox
MantisInABox2y ago
They have mentioned in passing that it might be in the pipeline, but they are not 100% on it as of yet
beninate
beninateOP2y ago
man. gonna have to mull over that, may be a deal breaker. there's no way to run a command on the server? even through the web UI?
Adam
Adam2y ago
No, there isn't
beninate
beninateOP2y ago
dang. that seems untenable. how is nobody else having an issue with that?
MantisInABox
MantisInABox2y ago
You can set custom start commands if that’s any help
Adam
Adam2y ago
Yep
beninate
beninateOP2y ago
not really no
Adam
Adam2y ago
What do you need ssh access for?
MantisInABox
MantisInABox2y ago
You would replace your Procfile with a railway.json file. That can trigger a shell script to run your commands followed by starting your server Just a suggestion
beninate
beninateOP2y ago
could be any number of things; fix an issue with a user's account, run some script, check on data, anything hm i can't quite picture, do you have an example somewhere?
Adam
Adam2y ago
Your database should not be a part of your main app. You should have an external db (through Railway or otherwise) which you can send commands to The reason why most users don't have an issue with not having ssh is because their app is constructed "correctly" Their app doesn't store any data
beninate
beninateOP2y ago
ho boy...
Adam
Adam2y ago
What db are you using? don't say sqlite
beninate
beninateOP2y ago
Postgres
Adam
Adam2y ago
Okay, that's better Your app will need a bit of retooling to get access to your data, but trust me, it's for the better Modular programming is the way to go
beninate
beninateOP2y ago
you're making a lot of assumptions here
Adam
Adam2y ago
How so
beninate
beninateOP2y ago
our app and our DB are already separate. I realize i can access DB data directly through Postgres. but that doesn't mean there's no need to ssh into the server
MantisInABox
MantisInABox2y ago
This is the railway.json file for the Django starter template. It can be modified to fit your needs
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS"
},
"deploy": {
"startCommand": "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn mysite.wsgi",
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS"
},
"deploy": {
"startCommand": "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn mysite.wsgi",
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
For the start command, you can move your rails start commands from Procfile to a shell script, then execute the shell script from the json file, but run all your commands priory to starting the server
Adam
Adam2y ago
You mentioned you'd need to access data stored in your app. Assuming that's in a db is a valid assumption. If you do need to store files, use a cloud bucket As for firing off commands, that won't be possible unless you build out an endpoint to hit that runs the command. If Railway isn't the platform for you with this restriction, that's your choice
beninate
beninateOP2y ago
wowzers... things were going so well
root
root2y ago
You don't need to use a cloud bucket to store files on Railway.
Adam
Adam2y ago
Right, but to access them you do, no?
root
root2y ago
Railway now has persistent storage, if you join the Priority Boarding program. I can actually see now why people would want to SSH in, or at least FTP in.
beninate
beninateOP2y ago
i never even asked anything about storing files in a cloud bucket. i simply asked how to get ssh or console access, an incredibly fundamental request as far as I can imagine, and am getting told that i don't actually need to and Railway isn't for me
Adam
Adam2y ago
I asked for your usecase for ssh, that's how cloud buckets came up We have this conversation with a new user every few days, I'm just going through the script
root
root2y ago
Railway doesn't support SSH because, up until recently, container storage was fully ephemeral and SSH access would just be confusing. Now, though, I can see why it would be useful.
MantisInABox
MantisInABox2y ago
He was looking for ssh access to be able to execute commands
beninate
beninateOP2y ago
im not trying to store anything, i just need to interface with the Rails server. ^^^^^ as i clearly stated
root
root2y ago
Fair enough, yeah. I'll make a feature request
beninate
beninateOP2y ago
thank you
MantisInABox
MantisInABox2y ago
My suggestion of using a shell script to run his desired commands, followed by launching his server would probably be the best method at this time
root
root2y ago
Allow SSH access to containers via CLI | Feature Requests | Railway
I have a project that works in my local environment but not once pushed to Railway. If I could login to the container like I can locally, I could determine
root
root2y ago
You should look into Tailscale - I haven't used it, but I've heard good things about it. I know it's more roundabout than it should be, but that's the best I can give you right now, sorry. I hope you can find more out about why your app isn't working.
beninate
beninateOP2y ago
thank you, will look into that. my app is actually working now, but it's very very routine to need to ssh in for some reason or another does anyone know if this means the feature itself is under review?
Adam
Adam2y ago
That means that the feature request is under review It's not in progress
root
root2y ago
Scroll up a bit:
MantisInABox
MantisInABox2y ago
Under consideration
root
root2y ago
They've decided to do it, but haven't done it yet.
beninate
beninateOP2y ago
right, ok
Want results from more Discord servers?
Add your server