So I was able to get the gem dependencies resolved, database set up, and fly deploy to work.
It took awhile to figure out how to run the rails server on port 3000 because whatever changes I made to fly.toml to change the internal port, they did not reflect when the server started. It still started on 8080. I ended up changing the server start command in fly.rake
sh 'bin/rails server -p 3000'
So now it is running off of 3000
When I run fly logs I see this:
2023-01-06T01:46:20Z runner[c78dfb7a] sjc [info]Starting instance
2023-01-06T01:46:20Z runner[c78dfb7a] sjc [info]Configuring virtual machine
2023-01-06T01:46:20Z runner[c78dfb7a] sjc [info]Pulling container image
2023-01-06T01:46:23Z runner[c78dfb7a] sjc [info]Unpacking image
2023-01-06T01:46:24Z runner[c78dfb7a] sjc [info]Preparing kernel init
2023-01-06T01:46:25Z runner[c78dfb7a] sjc [info]Configuring firecracker
2023-01-06T01:46:25Z runner[c78dfb7a] sjc [info]Starting virtual machine
2023-01-06T01:46:25Z app[c78dfb7a] sjc [info]Starting init (commit: f447594)…
2023-01-06T01:46:25Z app[c78dfb7a] sjc [info]Preparing to run: /bin/bash -o pipefail -c ${SERVER_COMMAND} as root
2023-01-06T01:46:25Z app[c78dfb7a] sjc [info]2023/01/06 01:46:25 listening on [fdaa:1:1b0f:a7b:b385:c78d:fb7a:2]:22 (DNS: [fdaa::3]:53)
2023-01-06T01:46:27Z app[c78dfb7a] sjc [info]fallocate -l 512M /swapfile
2023-01-06T01:46:27Z app[c78dfb7a] sjc [info]chmod 0600 /swapfile
2023-01-06T01:46:27Z app[c78dfb7a] sjc [info]mkswap /swapfile
2023-01-06T01:46:27Z app[c78dfb7a] sjc [info]Setting up swapspace version 1, size = 512 MiB (536866816 bytes)
2023-01-06T01:46:27Z app[c78dfb7a] sjc [info]no label, UUID=b2df5500-b1ab-41e3-9aff-3b852a2108f8
2023-01-06T01:46:27Z app[c78dfb7a] sjc [info]echo 10 > /proc/sys/vm/swappiness
2023-01-06T01:46:27Z app[c78dfb7a] sjc [info]swapon /swapfile
2023-01-06T01:46:27Z app[c78dfb7a] sjc [info]bin/rails server -p 3000
2023-01-06T01:46:28Z app[c78dfb7a] sjc [info]=> Booting WEBrick
2023-01-06T01:46:28Z app[c78dfb7a] sjc [info]=> Rails 6.0.0 application starting in production http://0.0.0.0:3000
2023-01-06T01:46:28Z app[c78dfb7a] sjc [info]=> Run rails server --help for more startup options
2023-01-06T01:46:29Z app[c78dfb7a] sjc [info]/app/vendor/bundle/ruby/2.7.0/gems/json-1.8.6/lib/json/common.rb:155: warning: Using the last argument as keyword parameters is deprecated
2023-01-06T01:46:29Z app[c78dfb7a] sjc [info][2023-01-06 01:46:29] INFO WEBrick 1.6.0
2023-01-06T01:46:29Z app[c78dfb7a] sjc [info][2023-01-06 01:46:29] INFO ruby 2.7.2 (2020-10-01) [x86_64-linux]
2023-01-06T01:46:29Z app[c78dfb7a] sjc [info][2023-01-06 01:46:29] INFO WEBrick::HTTPServer#start: pid=531 port=3000
2023-01-06T01:46:50Z runner[02929206] sjc [info]Shutting down virtual machine
2023-01-06T01:46:51Z app[02929206] sjc [info]Sending signal SIGINT to main child process w/ PID 521
2023-01-06T01:46:51Z app[02929206] sjc [info]rails aborted!
2023-01-06T01:46:51Z app[02929206] sjc [info]Interrupt:
2023-01-06T01:46:51Z app[02929206] sjc [info]/app/lib/tasks/fly.rake:21:in block (2 levels) in <top (required)>' 2023-01-06T01:46:51Z app[02929206] sjc [info]/app/vendor/bundle/ruby/2.7.0/gems/railties-6.0.0/lib/rails/commands/rake/rake_command.rb:23:in block in perform’
2023-01-06T01:46:51Z app[02929206] sjc [info]/app/vendor/bundle/ruby/2.7.0/gems/railties-6.0.0/lib/rails/commands/rake/rake_command.rb:20:in perform' 2023-01-06T01:46:51Z app[02929206] sjc [info]/app/vendor/bundle/ruby/2.7.0/gems/railties-6.0.0/lib/rails/command.rb:48:in invoke’
2023-01-06T01:46:51Z app[02929206] sjc [info]/app/vendor/bundle/ruby/2.7.0/gems/railties-6.0.0/lib/rails/commands.rb:18:in <top (required)>' 2023-01-06T01:46:51Z app[02929206] sjc [info]bin/rails:9:in require’
2023-01-06T01:46:51Z app[02929206] sjc [info]bin/rails:9:in `’
2023-01-06T01:46:51Z app[02929206] sjc [info]Tasks: TOP => fly:server
2023-01-06T01:46:51Z app[02929206] sjc [info](See full trace by running task with --trace)
2023-01-06T01:46:51Z app[02929206] sjc [info]Starting clean up.
App runs fine locally on 3000. Here is my fly.toml:
# commands used to deploy a Rails application
namespace :fly do
# BUILD step:
# - changes to the filesystem made here DO get deployed
# - NO access to secrets, volumes, databases
# - Failures here prevent deployment
task :build => 'assets:precompile'
# RELEASE step:
# - changes to the filesystem made here are DISCARDED
# - full access to secrets, databases
# - failures here prevent deployment
task :release => 'db:migrate'
# SERVER step:
# - changes to the filesystem made here are deployed
# - full access to secrets, databases
# - failures here result in VM being stated, shutdown, and rolled back
# to last successful deploy (if any).
task :server => :swapfile do
sh 'bin/rails server -p 3000'
end
# optional SWAPFILE task:
# - adjust fallocate size as needed
# - performance critical applications should scale memory to the
# point where swap is rarely used. 'fly scale help' for details.
# - disable by removing dependency on the :server task, thus:
# task :server do
task :swapfile do
sh 'fallocate -l 512M /swapfile'
sh 'chmod 0600 /swapfile'
sh 'mkswap /swapfile'
sh 'echo 10 > /proc/sys/vm/swappiness'
sh 'swapon /swapfile'
end
end
Is there some other configuration that I’m missing?
@yamjerky I just answered another question regarding a python server (gunicorn) only binding to ipv4. I think you need to bind to ipv6. It seems like your configuration is only listening to ipv4. I don’t know enough about rails to tell but maybe double check.
If all else fails I might just fire up a brand new rails app to see that work, then start porting things over. I’ll try to bang on it for a few more hours. Thanks for your help @ianjosephwilson and @rubys
I ended up just spinning up a new app and doing the ‘fly launch’. Once that was deployable I started moving over all the files. There were some gem dependencies that were not compatible so I trashed my gemlock and rebundled. That seemed to do the trick