Comments (11)
Going from monit to systemd would probably break a lot - especially, because opsworks is not maintained very well by amazon (to say the least), and I'm not sure how old systemd
versions are there :)
I like conditional restart/start approach better, because then we are not required to remove/detect restarts in workers. @olbrich what do you think?
from opsworks_ruby.
@olbrich Does the fix you created recently applies here (I mean, does it resolve the issue)? Or is it something unrelated?
from opsworks_ruby.
@ajgon I don't think I did anything that would explicitly fix this, but it's possible that it improved because the monit handling is a bit better now. I would recommend trying to reproduce with the latest version.
Also the line
Oct 14 17:44:25 myapp-server monit[920]: 'puma_rails' restart action failed
In the output makes me thing that the deploy is failing, so I'm not entirely sure what happens in that situation. I think we stop workers before a deploy and it may be that monit eventually figures out that the process should be running and tries to restart it on a failed deploy.
from opsworks_ruby.
I will try v1.21.1, thank!
In the output makes me thing that the deploy is failing, so I'm not entirely sure what happens in that situation.
In my case, the deploy is not failing. The deploy is success, puma and delayed_job processes are running correctly.
from opsworks_ruby.
I tried v1.21.1, I got fail to start puma process on create new instance 😢
Outputs:
ubuntu@myapp-server:~$ sudo monit summary
┌─────────────────────────────────┬────────────────────────────┬───────────────┐
│ Service Name │ Status │ Type │
├─────────────────────────────────┼────────────────────────────┼───────────────┤
│ myapp-server │ OK │ System │
├─────────────────────────────────┼────────────────────────────┼───────────────┤
│ puma_rails │ Execution failed | Does... │ Process │
├─────────────────────────────────┼────────────────────────────┼───────────────┤
│ opsworks-agent │ OK │ Process │
├─────────────────────────────────┼────────────────────────────┼───────────────┤
│ opsworks-agent-master-running │ OK │ Process │
├─────────────────────────────────┼────────────────────────────┼───────────────┤
│ delayed_job_rails-1 │ OK │ Process │
├─────────────────────────────────┼────────────────────────────┼───────────────┤
│ opsworks-agent-statistic-dae... │ OK │ File │
├─────────────────────────────────┼────────────────────────────┼───────────────┤
│ opsworks-agent-keep-alive-da... │ OK │ File │
└─────────────────────────────────┴────────────────────────────┴───────────────┘
ubuntu@myapp-server:~$ sudo monit status puma_rails
Process 'puma_rails'
status Execution failed | Does not exist
monitoring status Monitored
monitoring mode active
on reboot start
data collected Mon, 18 Oct 2021 12:37:44
ubuntu@myapp-server:~$ sudo journalctl | grep puma_rails
Oct 18 21:33:58 myapp-server monit[961]: 'puma_rails' process is not running
Oct 18 21:33:58 myapp-server monit[961]: 'puma_rails' trying to restart
Oct 18 21:33:58 myapp-server monit[961]: 'puma_rails' restart: '/bin/sh -c cd /srv/www/rails/current && AWS_ACCESS_KEY_ID=...'
Oct 18 21:35:28 myapp-server monit[961]: 'puma_rails' failed to restart (exit status 2) -- '/bin/sh -c cd /srv/www/rails/current && AWS_ACCESS_KEY_ID=...
Oct 18 21:36:13 myapp-server monit[961]: 'puma_rails' start on user request
Oct 18 21:36:13 myapp-server monit[961]: 'puma_rails' process is not running
Oct 18 21:36:13 myapp-server monit[961]: 'puma_rails' trying to restart
Oct 18 21:36:13 myapp-server monit[961]: 'puma_rails' restart: '/bin/sh -c cd /srv/www/rails/current && AWS_ACCESS_KEY_ID=...'
Oct 18 21:37:44 myapp-server monit[961]: 'puma_rails' failed to restart (exit status 0) --
Oct 18 21:38:44 myapp-server monit[961]: 'puma_rails' process is not running
ubuntu@myapp-server:~$ ps auxw|grep puma
ubuntu 26696 0.0 0.0 14860 1056 pts/0 S+ 21:47 0:00 grep --color=auto puma
ubuntu@myapp-server:~$ cat /run/lock/rails/puma.pid
cat: /run/lock/rails/puma.pid: No such file or directory
from opsworks_ruby.
Do the puma logs give you any indication of what the failure was?
from opsworks_ruby.
@olbrich
The puma log file did not exist. Is there anything else I should look at?
# puma.rb
pidfile "/run/lock/rails/puma.pid"
state_path "/run/lock/rails/puma.state"
stdout_redirect "/srv/www/rails/shared/log/puma.stdout.log", "/srv/www/rails/shared/log/puma.stderr.log", true
deploy@myapp-server:~$ cat /run/lock/rails/puma.pid
cat: /run/lock/rails/puma.pid: No such file or directory
deploy@myapp-server:~$ cat /run/lock/rails/puma.state
cat: /run/lock/rails/puma.state: No such file or directory
deploy@myapp-server:~$ cat /srv/www/rails/shared/log/puma.stdout.log
cat: /srv/www/rails/shared/log/puma.stdout.log: No such file or directory
deploy@myapp-server:~$ cat /srv/www/rails/shared/log/puma.stderr.log
cat: /srv/www/rails/shared/log/puma.stderr.log: No such file or directory
from opsworks_ruby.
pumactl restart
is failed because puma.state file does not exists.
https://github.com/puma/puma/blob/a6cdca85a15b2c277f64a5fa7572effb786fa9a1/lib/puma/control_cli.rb#L148
Oct 19 21:48:34 myapp-server monit[923]: 'puma_rails' process is not running
Oct 19 21:48:34 myapp-server monit[923]: 'puma_rails' trying to restart
Oct 19 21:48:34 myapp-server monit[923]: 'puma_rails' restart: '/bin/sh -c cd /srv/www/rails/current && AWS_ACCESS_KEY_ID=...
Oct 19 21:48:34 myapp-server puma-rails[15131]: State file not found: /run/lock/rails/puma.state
from opsworks_ruby.
It looks like the monit start
on the first deploy is not executed.
When I manually run sudo monit start puma_rails
, I have seen the following logs:
Oct 19 22:00:07 myapp-server monit[923]: 'puma_rails' start: '/bin/sh -c cd /srv/www/rails/current && AWS_ACCESS_KEY_ID=...
Puma will run successfully after the above log. puma.pid, puma.state files are created.
sudo journalctl | grep "'puma_rails' start:"
hits only logs that ran monit start
manually.
from opsworks_ruby.
This seems to be similar to the problem we addressed in #251.
Oct 19 23:03:54 myapp-server monit[960]: 'myapp-server' Monit reloaded
Oct 19 23:03:54 myapp-server monit[960]: 'puma_rails' process is not running
Oct 19 23:03:54 myapp-server monit[960]: 'puma_rails' trying to restart
Oct 19 23:03:54 myapp-server monit[960]: 'puma_rails' restart: '/bin/sh -c cd /srv/www/rails/current && AWS_ACCESS_KEY_ID=...
Oct 19 23:05:24 myapp-server monit[960]: 'puma_rails' failed to restart (exit status 0) -- '/bin/sh -c cd /srv/www/rails/current && AWS_ACCESS_KEY_ID=...
...
Oct 19 23:06:07 myapp-server monit[960]: 'puma_rails' start on user request
Oct 19 23:06:07 myapp-server monit[960]: Monit daemon with PID 960 awakened
Oct 19 23:06:07 myapp-server monit[960]: Awakened by User defined signal 1
Oct 19 23:06:07 myapp-server monit[960]: Reinitializing Monit -- control file '/etc/monit/monitrc'
Oct 19 23:06:07 myapp-server monit[25881]: Skipping 'allow localhost' -- host resolved to [::ffff:127.0.0.1] which is present in ACL already
Oct 19 23:06:07 myapp-server monit[960]: 'delayed_job_rails-1' restart on user request
Oct 19 23:06:07 myapp-server monit[960]: Monit daemon with PID 960 awakened
Oct 19 23:06:07 myapp-server monit[960]: Skipping 'allow localhost' -- host resolved to [::ffff:127.0.0.1] which is present in ACL already
Oct 19 23:06:07 myapp-server monit[960]: 'myapp-server' Monit reloaded
Oct 19 23:06:07 myapp-server monit[960]: 'puma_rails' process is not running
Oct 19 23:06:07 myapp-server monit[960]: 'puma_rails' trying to restart
Oct 19 23:06:07 myapp-server monit[960]: 'puma_rails' restart: '/bin/sh -c cd /srv/www/rails/current && AWS_ACCESS_KEY_ID=...
The monit start puma_rails
is requested, but actually monit restart
is working instead of monit start
.
It looks like to be cancelled because it is Reinitializing Monit
immediately after requesting monit start
.
After that, it looks like monit is repeatedly monit restart
by itself without the puma.state
file.
I assume this is because monit reload
twice, once for puma and once for delayed_job.
The monit reload
is now called immediately via notifies
from the configure hook of appserver and worker.
When I made the change to call monit reload
only once, the problem goes away.
Another approach that worked well was to change the command set for the restart program
in puma's monitrc, which dynamically switches between pumactl start
and pumactl restart
depending on the presence of the puma.state
file. See this diff for details.
@ajgon @olbrich
I can't decide which approach (or another approach) is better to use. What do you think?
from opsworks_ruby.
...Or should we move from monit to systemd for puma? 😂
from opsworks_ruby.
Related Issues (20)
- unicorn startup never returns, causes race condition at setup and during all restarts HOT 1
- ruby 2.7 not available on centos 7 or amazonlinux 2 HOT 1
- insecure by default: apache server-status is exposed HOT 1
- enforce_ownership step of deploy gets slower and slower on each deploy because of complexity in shared/cache/assets HOT 5
- Migrate to travis-ci.com or use github actions instead HOT 1
- Support for GoodJob? HOT 3
- Brightbox ruby-ng disontinued ? HOT 2
- SSL Error With Nginx Key Download HOT 14
- remove
- Sidekiq missing -e param HOT 1
- Docker change to installed chef HOT 1
- Rubocop Target Ruby Version HOT 2
- Having worker and appserver running only on particular layers HOT 1
- puma does not restart after deploy that changes only environment variables HOT 6
- The change of environment variables are applied to puma worker processes HOT 3
- Column change migrations fails HOT 1
- Setup/configure constantly rerunning after upgrading to Ubuntu 18.04/OpsWorks agent 4040. Also unable to upload chef.logs to s3. HOT 2
- Sidekiq goes quiet after deploy HOT 2
- About archiving the project HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opsworks_ruby.