Cannot deploy a Rails app: "A server is already running. Check /app/tmp/pids/server.pid."

Cannot deploy my Rails app with the following commands on an empty organization (meaning no apps in the organization):

flyctl launch (then manually select organization, location etc.)
flyctl scale vm dedicated-cpu-1x
flyctl deploy

The logs are:

2022-12-20T01:59:56.696 app[be5939b8] nrt [info] Starting init (commit: f447594)...

2022-12-20T01:59:56.796 app[be5939b8] nrt [info] Preparing to run: `/bin/bash -o pipefail -c ${SERVER_COMMAND}` as root

2022-12-20T01:59:56.940 app[be5939b8] nrt [info] 2022/12/20 01:59:56 listening on [fdaa:1:548:a7b:d829:be59:39b8:2]:22 (DNS: [fdaa::3]:53)

2022-12-20T02:00:01.525 app[be5939b8] nrt [info] bin/rails server

2022-12-20T02:00:03.300 app[be5939b8] nrt [info] => Booting Puma

2022-12-20T02:00:03.300 app[be5939b8] nrt [info] => Rails 6.1.3.2 application starting in production

2022-12-20T02:00:03.300 app[be5939b8] nrt [info] => Run `bin/rails server --help` for more startup options

2022-12-20T02:00:03.300 app[be5939b8] nrt [info] A server is already running. Check /app/tmp/pids/server.pid.

2022-12-20T02:00:03.300 app[be5939b8] nrt [info] Exiting

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] rails aborted!

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] Command failed with status (1): [bin/rails server...]

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/lib/rake/file_utils.rb:67:in `block in create_shell_runner'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/lib/rake/file_utils.rb:57:in `sh'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/lib/tasks/fly.rake:21:in `block (2 levels) in <main>'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `block in execute'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `each'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `execute'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:219:in `block in invoke_with_call_chain'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `synchronize'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `invoke_with_call_chain'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:188:in `invoke'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:160:in `invoke_task'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `block (2 levels) in top_level'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `each'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `block in top_level'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:125:in `run_with_threads'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:110:in `top_level'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.3.2/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:186:in `standard_exception_handling'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.3.2/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/lib/rake/rake_module.rb:59:in `with_application'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.3.2/lib/rails/commands/rake/rake_command.rb:18:in `perform'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.3.2/lib/rails/command.rb:52:in `invoke'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.3.2/lib/rails/commands.rb:18:in `<main>'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] /app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] Tasks: TOP => fly:server

2022-12-20T02:00:03.327 app[be5939b8] nrt [info] (See full trace by running task with --trace)

2022-12-20T02:00:03.881 app[be5939b8] nrt [info] Starting clean up.

Try making a one line change to your .dockerignore file:

Change:

!tmp/pids

To:

!tmp/pids/.keep

If that works for you, I’ll change the template that flyctl uses.

1 Like

It worked. Wow. Spent half a day on this. Thank you.

The fix will be in the next version of flyctl: Ensure deployed tmp/pids directory is empty by rubys · Pull Request #1528 · superfly/flyctl · GitHub

1 Like