Could we also get a way to run a long running process in detached mode?
If you have bash in your image, you should be able to do something like this:
fly ssh console -C "bash nohup ./process &"
You should also check out the fly machine run
command. This will let you run one off VMs until they exit successfully (among other things).
Happy to find this thread, was tough to find the rails console via ssh.
Perhaps a beginner follow-up question:
I’ve started the rails console process via /cnb/process/console
but it either breaks right away, after the first input or is so laggy that it’s pretty much unusable.
Am I doing something wrong, or there just minimal support for it yet?
I’m running into the same problem as Elvinas.
Using /cnb/process/console
does not work for me, the ssh session ends every time after a few seconds.
Oh I just replied to your other post. Sometimes Rails VMs crash with an out of memory error when they don’t have enough RAM and you run the console. That would end the session.
If you run fly status --all
after this happens you might see a VM in a “failed” state. You can run fly vm status <id>
on that one and it should tell you why it exited.
Thanks for your help, the following seems to be working for me :
fly ssh console
launcher rails console
Is your app using a buildpack or a Dockerfile? You can tell from the [build]
section of your fly.toml
.
If it’s Rails 7, we generate a Dockerfile for it (buildpacks are for older Rails). Assuming that’s the case, you should be able to get Rails console by running:
-> fly ssh console
$ cd /app/
$ rails console
There may be a one liner for the SSH command, we’ll look!
I changed it to use 512mb of ram and I can access the console now!
I have 2GB on a staging machine and I can’t get any of this to work.
❯ fly ssh console -C "bash nohup ./process &" -a app
Connecting to top1.nearest.of.app.internal... complete
/usr/bin/nohup: /usr/bin/nohup: cannot execute binary file
Similar error for /cnb/process/console
.
# launcher rails console
/bin/sh: 2: launcher: not found
# ./bin/rails console
Your Ruby version is 2.7.0, but your Gemfile specified 2.7.6
Still looking at other community topics to find what I am missing, I used turboku to bootstrap this app, so something must be different.
Try running fly ssh console -C "/bin/bash"
. Then run ls -la /cnb/process
. Does it show anything?
You may need to run something like /lnb/launcher rails console
.
fly ssh console -C "/bin/bash" -a app-name
Connecting to top1.nearest.of.<app-name>.internal... complete
root@96186c8f:/# ls -la /cnb/process
ls: cannot access '/cnb/process': No such file or directory
root@96186c8f:/# /lnb/launcher rails console
bash: /lnb/launcher: No such file or directory
root@96186c8f:/# /cnb/launcher rails console
bash: /cnb/launcher: No such file or directory
I might be in a new architecture or something because I’ve never seen the cnb
dir:
root@96186c8f:/# ls
app/ bin/ boot/ dev/ etc/ .fly/ home/ lib/ lib32/
lib64/ libx32/ media/ mnt/ opt/ proc/ root/ run/ sbin/
srv/ sys/ tmp/ usr/ var/
root@96186c8f:/# find . | grep launcher
./app/.apt/usr/include/glib-2.0/gio/gsubprocesslauncher.h
./app/.apt/usr/libexec/at-spi-bus-launcher
./app/vendor/bundle/ruby/2.7.0/gems/puma-5.6.4/lib/puma/launcher.rb
./app/vendor/bundle/ruby/2.7.0/gems/sidekiq-6.4.0/lib/sidekiq/launcher.rb
./usr/share/locale-langpack/en_GB/LC_MESSAGES/ubuntu-default-launchers.mo
./usr/share/locale-langpack/en_AU/LC_MESSAGES/ubuntu-default-launchers.mo
./usr/share/locale-langpack/en_CA/LC_MESSAGES/ubuntu-default-launchers.mo
./usr/bin/cautious-launcher
root@96186c8f:/# find . | grep cnb
# no output
I’m running into this very same issue.
Apparently this is due to using multiple buildpacks.
Here is the list of my buildpacks in case that helps:
=== appname Buildpack URLs
1. heroku/metrics
2. https://github.com/heroku/heroku-buildpack-activestorage-preview
3. heroku-community/apt
4. heroku/ruby
The 3rd one allows me to define apt
dependencies, here is the Aptfile:
libglib2.0-0
libglib2.0-dev
libpoppler-glib8
libheif-dev
libvips-dev
libvips
I added them mostly to be able to resize uploaded images.
I’m using pretty standard buildpacks:
[build]
builder = "heroku/buildpacks:20"
buildpacks = ["heroku/nodejs", "heroku/ruby"]
So I was able to get this working by:
fly ssh console
bash
cd /app
cat profile.d/ruby.sh # executing is denied
Exporting the variables found there manually sets up what we need. Then we can do bin/rails c
and the console loads.