Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Commit

Permalink
fix(appserver): use pumactl start for restart if the puma.state f…
Browse files Browse the repository at this point in the history
…ile does not exists (#276)

Fixes #274
  • Loading branch information
kzkn authored and ajgon committed Feb 9, 2022
1 parent fd79af2 commit c2c8713
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions spec/unit/recipes/configure_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@
.with_content <<~MONITRC
check process puma_dummy_project with pidfile /run/lock/dummy_project/puma.pid
start program = "/bin/sh -c 'cd /srv/www/dummy_project/current && ENV_VAR1="test" ENV_VAR2="some data" HANAMI_ENV="staging" DATABASE_URL="mysql2://dbuser:03c1bc98cdd5eb2f9c75@dummy-project.c298jfowejf.us-west-2.rds.amazon.com:3265/dummydb" HOME="/home/deploy" USER="deploy" bundle exec pumactl -F /srv/www/dummy_project/shared/config/puma.rb start | logger -t puma-dummy_project'" as uid "deploy" and gid "deploy" with timeout 90 seconds
restart program = "/bin/sh -c 'cd /srv/www/dummy_project/current && ENV_VAR1="test" ENV_VAR2="some data" HANAMI_ENV="staging" DATABASE_URL="mysql2://dbuser:03c1bc98cdd5eb2f9c75@dummy-project.c298jfowejf.us-west-2.rds.amazon.com:3265/dummydb" HOME="/home/deploy" USER="deploy" bundle exec pumactl -F /srv/www/dummy_project/shared/config/puma.rb restart | logger -t puma-dummy_project'" as uid "deploy" and gid "deploy" with timeout 90 seconds
restart program = "/bin/sh -c '(cd /srv/www/dummy_project/current && if [ -f /run/lock/dummy_project/puma.state ]; then ENV_VAR1="test" ENV_VAR2="some data" HANAMI_ENV="staging" DATABASE_URL="mysql2://dbuser:03c1bc98cdd5eb2f9c75@dummy-project.c298jfowejf.us-west-2.rds.amazon.com:3265/dummydb" HOME="/home/deploy" USER="deploy" bundle exec pumactl -F /srv/www/dummy_project/shared/config/puma.rb restart; else ENV_VAR1="test" ENV_VAR2="some data" HANAMI_ENV="staging" DATABASE_URL="mysql2://dbuser:03c1bc98cdd5eb2f9c75@dummy-project.c298jfowejf.us-west-2.rds.amazon.com:3265/dummydb" HOME="/home/deploy" USER="deploy" bundle exec pumactl -F /srv/www/dummy_project/shared/config/puma.rb start; fi) | logger -t puma-dummy_project'" as uid "deploy" and gid "deploy" with timeout 90 seconds
stop program = "/bin/sh -c 'cd /srv/www/dummy_project/current && ENV_VAR1="test" ENV_VAR2="some data" HANAMI_ENV="staging" DATABASE_URL="mysql2://dbuser:03c1bc98cdd5eb2f9c75@dummy-project.c298jfowejf.us-west-2.rds.amazon.com:3265/dummydb" HOME="/home/deploy" USER="deploy" bundle exec pumactl -F /srv/www/dummy_project/shared/config/puma.rb stop | logger -t puma-dummy_project'" as uid "deploy" and gid "deploy" with timeout 90 seconds
group puma_dummy_project_group
MONITRC
Expand Down Expand Up @@ -914,7 +914,7 @@
.with_content <<~MONITRC
check process puma_dummy_project with pidfile /run/lock/dummy_project/puma.pid
start program = "/bin/sh -c 'cd /srv/www/dummy_project/current && ENV_VAR1="test" ENV_VAR2="some data" HANAMI_ENV="staging" DATABASE_URL="mysql2://dbuser:03c1bc98cdd5eb2f9c75@dummy-project.c298jfowejf.us-west-2.rds.amazon.com:3265/dummydb" HOME="/home/deploy" USER="deploy" bundle exec pumactl -F /srv/www/dummy_project/shared/config/puma.rb start | logger -t puma-dummy_project'" as uid "deploy" and gid "deploy" with timeout 90 seconds
restart program = "/bin/sh -c 'cd /srv/www/dummy_project/current && ENV_VAR1="test" ENV_VAR2="some data" HANAMI_ENV="staging" DATABASE_URL="mysql2://dbuser:03c1bc98cdd5eb2f9c75@dummy-project.c298jfowejf.us-west-2.rds.amazon.com:3265/dummydb" HOME="/home/deploy" USER="deploy" bundle exec pumactl -F /srv/www/dummy_project/shared/config/puma.rb restart | logger -t puma-dummy_project'" as uid "deploy" and gid "deploy" with timeout 90 seconds
restart program = "/bin/sh -c '(cd /srv/www/dummy_project/current && if [ -f /run/lock/dummy_project/puma.state ]; then ENV_VAR1="test" ENV_VAR2="some data" HANAMI_ENV="staging" DATABASE_URL="mysql2://dbuser:03c1bc98cdd5eb2f9c75@dummy-project.c298jfowejf.us-west-2.rds.amazon.com:3265/dummydb" HOME="/home/deploy" USER="deploy" bundle exec pumactl -F /srv/www/dummy_project/shared/config/puma.rb restart; else ENV_VAR1="test" ENV_VAR2="some data" HANAMI_ENV="staging" DATABASE_URL="mysql2://dbuser:03c1bc98cdd5eb2f9c75@dummy-project.c298jfowejf.us-west-2.rds.amazon.com:3265/dummydb" HOME="/home/deploy" USER="deploy" bundle exec pumactl -F /srv/www/dummy_project/shared/config/puma.rb start; fi) | logger -t puma-dummy_project'" as uid "deploy" and gid "deploy" with timeout 90 seconds
stop program = "/bin/sh -c 'cd /srv/www/dummy_project/current && ENV_VAR1="test" ENV_VAR2="some data" HANAMI_ENV="staging" DATABASE_URL="mysql2://dbuser:03c1bc98cdd5eb2f9c75@dummy-project.c298jfowejf.us-west-2.rds.amazon.com:3265/dummydb" HOME="/home/deploy" USER="deploy" bundle exec pumactl -F /srv/www/dummy_project/shared/config/puma.rb stop | logger -t puma-dummy_project'" as uid "deploy" and gid "deploy" with timeout 90 seconds
group puma_dummy_project_group
MONITRC
Expand Down
3 changes: 2 additions & 1 deletion templates/default/puma.monitrc.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<% pid_file = "/run/lock/#{@app_shortname}/#{@appserver_name}.pid" %>
<% state_file = "/run/lock/#{@app_shortname}/#{@appserver_name}.state" %>
<% app_dir = File.join(@deploy_to, 'current') %>
<% config_file = File.join(@deploy_to, 'shared/config/puma.rb') %>
<% env = @environment.map {|k,v| "#{k}=\"#{v}\""}.join(' ') %>
<% pumactl = "#{env} bundle exec pumactl -F #{config_file}"%>

check process <%= @appserver_name %>_<%= @app_shortname %> with pidfile <%= pid_file %>
start program = "/bin/sh -c 'cd <%= app_dir %> && <%= pumactl %> start | logger -t <%= @appserver_name %>-<%= @app_shortname %>'" as uid "<%= node['deployer']['user'] %>" and gid "<%= node['deployer']['group'] %>" with timeout 90 seconds
restart program = "/bin/sh -c 'cd <%= app_dir %> && <%= pumactl %> restart | logger -t <%= @appserver_name %>-<%= @app_shortname %>'" as uid "<%= node['deployer']['user'] %>" and gid "<%= node['deployer']['group'] %>" with timeout 90 seconds
restart program = "/bin/sh -c '(cd <%= app_dir %> && if [ -f <%= state_file %> ]; then <%= pumactl %> restart; else <%= pumactl %> start; fi) | logger -t <%= @appserver_name %>-<%= @app_shortname %>'" as uid "<%= node['deployer']['user'] %>" and gid "<%= node['deployer']['group'] %>" with timeout 90 seconds
stop program = "/bin/sh -c 'cd <%= app_dir %> && <%= pumactl %> stop | logger -t <%= @appserver_name %>-<%= @app_shortname %>'" as uid "<%= node['deployer']['user'] %>" and gid "<%= node['deployer']['group'] %>" with timeout 90 seconds
group <%= @appserver_name %>_<%= @app_shortname.to_s %>_group

0 comments on commit c2c8713

Please sign in to comment.