I'm having trouble starting Resque on AWS Elastic Beanstalk with the Ruby 2.7 running on 64bit Amazon Linux 2/3.4.3 platform. My Procfile is as follows:
Procfile:
web: bundle exec puma -C /opt/elasticbeanstalk/config/private/pumaconf.rb
worker: RACK_ENV=production BACKGROUND=yes QUEUE=* PIDFILE=/var/pids/worker.pid bundle exec rake resque:work
The worker process keeps getting killed after starting. I get no error messages in resque.log. The error messages I get are as follows:
Mar 10 18:18:37 ip-172-31-23-44 systemd: Starting This is web daemon...
Mar 10 18:18:37 ip-172-31-23-44 systemd: Started This is web daemon.
Mar 10 18:18:37 ip-172-31-23-44 systemd: Reloading.
Mar 10 18:18:37 ip-172-31-23-44 systemd: Reloading.
Mar 10 18:18:37 ip-172-31-23-44 systemd: Reloading.
Mar 10 18:18:37 ip-172-31-23-44 systemd: Starting This is worker daemon...
Mar 10 18:18:37 ip-172-31-23-44 systemd: Started This is worker daemon.
Mar 10 18:18:37 ip-172-31-23-44 systemd: Reloading.
Mar 10 18:18:38 ip-172-31-23-44 systemd: Starting The nginx HTTP and reverse proxy server...
Mar 10 18:18:38 ip-172-31-23-44 nginx: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Mar 10 18:18:38 ip-172-31-23-44 nginx: nginx: configuration file /etc/nginx/nginx.conf test is successful
Mar 10 18:18:38 ip-172-31-23-44 systemd: Started The nginx HTTP and reverse proxy server.
Mar 10 18:18:38 ip-172-31-23-44 web: [4087] Puma starting in cluster mode...
Mar 10 18:18:38 ip-172-31-23-44 web: [4087] * Puma version: 5.6.2 (ruby 2.7.5-p203) ("Birdie's Version")
Mar 10 18:18:38 ip-172-31-23-44 web: [4087] * Min threads: 8
Mar 10 18:18:38 ip-172-31-23-44 web: [4087] * Max threads: 32
Mar 10 18:18:38 ip-172-31-23-44 web: [4087] * Environment: production
Mar 10 18:18:38 ip-172-31-23-44 web: [4087] * Master PID: 4087
Mar 10 18:18:38 ip-172-31-23-44 web: [4087] * Workers: 1
Mar 10 18:18:38 ip-172-31-23-44 web: [4087] * Restarts: (✔) hot (✔) phased
Mar 10 18:18:38 ip-172-31-23-44 web: [4087] * Listening on unix:///var/run/puma/my_app.sock
Mar 10 18:18:38 ip-172-31-23-44 web: [4087] Use Ctrl-C to stop
Mar 10 18:18:38 ip-172-31-23-44 web: [4087] ! WARNING: Detected running cluster mode with 1 worker.
Mar 10 18:18:38 ip-172-31-23-44 web: [4087] ! Running Puma in cluster mode with a single worker is often a misconfiguration.
Mar 10 18:18:38 ip-172-31-23-44 web: [4087] ! Consider running Puma in single-mode (workers = 0) in order to reduce memory overhead.
Mar 10 18:18:38 ip-172-31-23-44 web: [4087] ! Set the `silence_single_worker_warning` option to silence this warning message.
Mar 10 18:18:39 ip-172-31-23-44 worker: /opt/rubies/ruby-2.7.5/lib/ruby/gems/2.7.0/gems/json-1.8.6/lib/json/common.rb:155: warning: Using the last argument as keyword parameters is deprecated
Mar 10 18:18:40 ip-172-31-23-44 worker: /opt/rubies/ruby-2.7.5/lib/ruby/gems/2.7.0/bundler/gems/rhoconnect-f756fb2318a8/lib/rhoconnect/application/init.rb:6: warning: already initialized constant ROOT_PATH
Mar 10 18:18:40 ip-172-31-23-44 worker: /var/app/current/Rakefile:7: warning: previous definition of ROOT_PATH was here
Mar 10 18:18:41 ip-172-31-23-44 worker: [4179][06:18:40.663 PM 2022-03-10] Rhoconnect Server v7.1.0 started...
Mar 10 18:18:41 ip-172-31-23-44 worker: [4179][06:18:41.365 PM 2022-03-10] No `package.json` detected, disabling JavaScript support.
Mar 10 18:18:41 ip-172-31-23-44 systemd: worker.service holdoff time over, scheduling restart.
Mar 10 18:18:41 ip-172-31-23-44 systemd: Stopped This is worker daemon.
Mar 10 18:18:41 ip-172-31-23-44 systemd: Starting This is worker daemon...
Mar 10 18:18:41 ip-172-31-23-44 systemd: Started This is worker daemon.
Mar 10 18:18:42 ip-172-31-23-44 worker: /opt/rubies/ruby-2.7.5/lib/ruby/gems/2.7.0/gems/json-1.8.6/lib/json/common.rb:155: warning: Using the last argument as keyword parameters is deprecated
Mar 10 18:18:42 ip-172-31-23-44 healthd: Version 2 of the Ruby SDK will enter maintenance mode as of November 20, 2020. To continue receiving service updates and new features, please upgrade to Version 3. More information can be found here: https://aws.amazon.com/blogs/developer/deprecation-schedule-for-aws-sdk-for-ruby-v2/
Mar 10 18:18:42 ip-172-31-23-44 worker: /opt/rubies/ruby-2.7.5/lib/ruby/gems/2.7.0/bundler/gems/rhoconnect-f756fb2318a8/lib/rhoconnect/application/init.rb:6: warning: already initialized constant ROOT_PATH
Mar 10 18:18:42 ip-172-31-23-44 worker: /var/app/current/Rakefile:7: warning: previous definition of ROOT_PATH was here
Mar 10 18:18:43 ip-172-31-23-44 worker: [4283][06:18:43.001 PM 2022-03-10] Rhoconnect Server v7.1.0 started...
Mar 10 18:18:43 ip-172-31-23-44 worker: [4283][06:18:43.426 PM 2022-03-10] No `package.json` detected, disabling JavaScript support.
Mar 10 18:18:43 ip-172-31-23-44 systemd: worker.service holdoff time over, scheduling restart.
Mar 10 18:18:43 ip-172-31-23-44 systemd: Stopped This is worker daemon.
Mar 10 18:18:43 ip-172-31-23-44 systemd: Starting This is worker daemon...
Mar 10 18:18:43 ip-172-31-23-44 systemd: Started This is worker daemon.
Mar 10 18:18:44 ip-172-31-23-44 worker: /opt/rubies/ruby-2.7.5/lib/ruby/gems/2.7.0/gems/json-1.8.6/lib/json/common.rb:155: warning: Using the last argument as keyword parameters is deprecated
Mar 10 18:18:44 ip-172-31-23-44 worker: /opt/rubies/ruby-2.7.5/lib/ruby/gems/2.7.0/bundler/gems/rhoconnect-f756fb2318a8/lib/rhoconnect/application/init.rb:6: warning: already initialized constant ROOT_PATH
Mar 10 18:18:44 ip-172-31-23-44 worker: /var/app/current/Rakefile:7: warning: previous definition of ROOT_PATH was here
Mar 10 18:18:45 ip-172-31-23-44 worker: [4322][06:18:44.922 PM 2022-03-10] Rhoconnect Server v7.1.0 started...
Mar 10 18:18:45 ip-172-31-23-44 worker: [4322][06:18:45.345 PM 2022-03-10] No `package.json` detected, disabling JavaScript support.
Mar 10 18:18:45 ip-172-31-23-44 systemd: worker.service holdoff time over, scheduling restart.
Mar 10 18:18:45 ip-172-31-23-44 systemd: Stopped This is worker daemon.
Mar 10 18:18:45 ip-172-31-23-44 systemd: Starting This is worker daemon...
Mar 10 18:18:45 ip-172-31-23-44 systemd: Started This is worker daemon.
Mar 10 18:18:46 ip-172-31-23-44 worker: /opt/rubies/ruby-2.7.5/lib/ruby/gems/2.7.0/gems/json-1.8.6/lib/json/common.rb:155: warning: Using the last argument as keyword parameters is deprecated
Mar 10 18:18:46 ip-172-31-23-44 worker: /opt/rubies/ruby-2.7.5/lib/ruby/gems/2.7.0/bundler/gems/rhoconnect-f756fb2318a8/lib/rhoconnect/application/init.rb:6: warning: already initialized constant ROOT_PATH
Mar 10 18:18:46 ip-172-31-23-44 worker: /var/app/current/Rakefile:7: warning: previous definition of ROOT_PATH was here
Mar 10 18:18:47 ip-172-31-23-44 worker: [4360][06:18:46.915 PM 2022-03-10] Rhoconnect Server v7.1.0 started...
Mar 10 18:18:47 ip-172-31-23-44 worker: [4360][06:18:47.329 PM 2022-03-10] No `package.json` detected, disabling JavaScript support.
Mar 10 18:18:47 ip-172-31-23-44 systemd: worker.service holdoff time over, scheduling restart.
Mar 10 18:18:47 ip-172-31-23-44 systemd: Stopped This is worker daemon.
Mar 10 18:18:47 ip-172-31-23-44 systemd: Starting This is worker daemon...
Mar 10 18:18:47 ip-172-31-23-44 systemd: Started This is worker daemon.
Mar 10 18:18:48 ip-172-31-23-44 worker: /opt/rubies/ruby-2.7.5/lib/ruby/gems/2.7.0/gems/json-1.8.6/lib/json/common.rb:155: warning: Using the last argument as keyword parameters is deprecated
Mar 10 18:18:48 ip-172-31-23-44 worker: /opt/rubies/ruby-2.7.5/lib/ruby/gems/2.7.0/bundler/gems/rhoconnect-f756fb2318a8/lib/rhoconnect/application/init.rb:6: warning: already initialized constant ROOT_PATH
Mar 10 18:18:48 ip-172-31-23-44 worker: /var/app/current/Rakefile:7: warning: previous definition of ROOT_PATH was here
Mar 10 18:18:49 ip-172-31-23-44 worker: [4398][06:18:48.922 PM 2022-03-10] Rhoconnect Server v7.1.0 started...
Mar 10 18:18:49 ip-172-31-23-44 worker: [4398][06:18:49.330 PM 2022-03-10] No `package.json` detected, disabling JavaScript support.
Mar 10 18:18:49 ip-172-31-23-44 systemd: worker.service holdoff time over, scheduling restart.
Mar 10 18:18:49 ip-172-31-23-44 systemd: Stopped This is worker daemon.
Mar 10 18:18:49 ip-172-31-23-44 systemd: Starting This is worker daemon...
Mar 10 18:18:49 ip-172-31-23-44 systemd: Started This is worker daemon.
Mar 10 18:18:50 ip-172-31-23-44 worker: /opt/rubies/ruby-2.7.5/lib/ruby/gems/2.7.0/gems/json-1.8.6/lib/json/common.rb:155: warning: Using the last argument as keyword parameters is deprecated
Mar 10 18:18:50 ip-172-31-23-44 worker: /opt/rubies/ruby-2.7.5/lib/ruby/gems/2.7.0/bundler/gems/rhoconnect-f756fb2318a8/lib/rhoconnect/application/init.rb:6: warning: already initialized constant ROOT_PATH
Mar 10 18:18:50 ip-172-31-23-44 worker: /var/app/current/Rakefile:7: warning: previous definition of ROOT_PATH was here
Mar 10 18:18:51 ip-172-31-23-44 worker: [4436][06:18:50.918 PM 2022-03-10] Rhoconnect Server v7.1.0 started...
Mar 10 18:18:51 ip-172-31-23-44 worker: [4436][06:18:51.323 PM 2022-03-10] No `package.json` detected, disabling JavaScript support.
Mar 10 18:18:51 ip-172-31-23-44 systemd: worker.service holdoff time over, scheduling restart.
Mar 10 18:18:51 ip-172-31-23-44 systemd: Stopped This is worker daemon.
Mar 10 18:18:51 ip-172-31-23-44 systemd: start request repeated too quickly for worker.service
Mar 10 18:18:51 ip-172-31-23-44 systemd: Failed to start This is worker daemon.
Mar 10 18:18:51 ip-172-31-23-44 systemd: Unit worker.service entered failed state.
Mar 10 18:18:51 ip-172-31-23-44 systemd: worker.service failed.
I can manually start resque with the same command and then environment is "Green" and works:
eb ssh
[ec2-user@ip-172-31-23-44 current]$ sudo su -
Last login: Thu Mar 10 18:18:36 UTC 2022
[root@ip-172-31-23-44 ~]# cd /var/app/current
[root@ip-172-31-23-44 current]# RACK_ENV=production BACKGROUND=yes QUEUE=* PIDFILE=/var/pids/worker.pid bundle exec rake resque:work
/opt/rubies/ruby-2.7.5/lib/ruby/gems/2.7.0/gems/json-1.8.6/lib/json/common.rb:155: warning: Using the last argument as keyword parameters is deprecated
/opt/rubies/ruby-2.7.5/lib/ruby/gems/2.7.0/bundler/gems/rhoconnect-f756fb2318a8/lib/rhoconnect/application/init.rb:6: warning: already initialized constant ROOT_PATH
/var/app/current/Rakefile:7: warning: previous definition of ROOT_PATH was here
[4752][06:22:34.927 PM 2022-03-10] Rhoconnect Server v7.1.0 started...
[4752][06:22:35.338 PM 2022-03-10] No `package.json` detected, disabling JavaScript support.
[root@ip-172-31-23-44 current]#
The automatically generated worker.service file is:
[Unit]
Description=This is worker daemon
PartOf=eb-app.target
[Service]
User=webapp
Type=simple
ExecStart=/bin/sh -c "RACK_ENV=production BACKGROUND=yes QUEUE=* PIDFILE=/var/pids/worker.pid bundle exec rake resque:work"
ExecStartPost=/bin/sh -c "systemctl show -p MainPID worker.service | cut -d= -f2 > /var/pids/worker.pid"
ExecStopPost=/bin/sh -c "rm -f /var/pids/worker.pid"
ExecStopPost=/bin/sh -c ""
Restart=always
EnvironmentFile=/opt/elasticbeanstalk/deployment/env
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=worker
WorkingDirectory=/var/app/current/
[Install]
WantedBy=multi-user.target
The issue is with the BACKGROUND=true option for Resque. To make it work with AWS ElasticBeanstalk, simply change your Procfile to:
web: bundle exec puma -C /opt/elasticbeanstalk/config/private/pumaconf.rb
worker: bundle exec rake resque:work
and make sure you do not have the BACKGROUND env variable set anywhere.