I'm working in a continous delivery solution for a couple of applications and one of them includes a series of Dashboards made with Dashing and I've found and interesting case of deployment that I'll try to reproduce:
I've tested the deployment in Ubuntu 13 on an Amazon EC2 instance. It was provisioned with chef to have a basic Nginx-Puma and later Nginx-Unicorn config to run the dashboard over Ruby 2.1.1
So first create a Dashing dashboard:
$ dashing new dashboard
Add the follwing to the Gemfile
gem 'puma'
gem 'unicorn'
group :development, :test do
# gem 'capistrano3-puma'
gem 'capistrano3-unicorn'
end
And comment the one that your are not trying to deploy. Deploy to your instance and check the deployment output:
Running Automatically the Application Server Script
For Unicorn:
[06824030] Running /usr/bin/env [ -e /var/www/application/current/tmp/pids/unicorn.pid ] && kill -0 `cat /var/www/application/current/tmp/pids/unicorn.pid` on 54.164.27.12
DEBUG[06824030] Command: [ -e /var/www/application/current/tmp/pids/unicorn.pid ] && kill -0 `cat /var/www/application/current/tmp/pids/unicorn.pid`
DEBUG[06824030] Finished in 0.266 seconds with exit status 1 (failed).
INFO[d849a4f5] Running RBENV_ROOT=/opt/rbenv RBENV_VERSION=2.1.1 /opt/rbenv/bin/rbenv exec bundle exec unicorn -c /var/www/application/current/config/unicorn/config.rb -E deployment -D on 54.164.27.12
DEBUG[d849a4f5] Command: cd /var/www/application/current && ( PATH=~/.rbenv/shims:~/.rbenv/bin:$PATH RBENV_ROOT=/opt/rbenv RBENV_VERSION=2.1.1 RAILS_ENV=staging RBENV_ROOT=/opt/rbenv RBENV_VERSION=2.1.1 /opt/rbenv/bin/rbenv exec bundle exec unicorn -c /var/www/application/current/config/unicorn/config.rb -E deployment -D )
For Puma
[36c2f618] Running /usr/bin/env kill -0 $( cat /var/www/application/shared/tmp/pids/puma.pid ) on 54.164.27.12
DEBUG[36c2f618] Command: kill -0 $( cat /var/www/application/shared/tmp/pids/puma.pid )
DEBUG[36c2f618] Finished in 0.265 seconds with exit status 0 (successful).
INFO[39a64997] Running RBENV_ROOT=/opt/rbenv RBENV_VERSION=2.1.1 /opt/rbenv/bin/rbenv exec bundle exec pumactl -S /var/www/application/shared/tmp/pids/puma.state stop on 54.164.27.12
DEBUG[39a64997] Command: cd /var/www/application/current && ( PATH=~/.rbenv/shims:~/.rbenv/bin:$PATH RBENV_ROOT=/opt/rbenv RBENV_VERSION=2.1.1 RACK_ENV=staging RBENV_ROOT=/opt/rbenv RBENV_VERSION=2.1.1 /opt/rbenv/bin/rbenv exec bundle exec pumactl -S /var/www/application/shared/tmp/pids/puma.state stop )
DEBUG[39a64997] Command stop sent success
INFO[39a64997] Finished in 1.061 seconds with exit status 0 (successful).
DEBUG[ad6525c4] Running /usr/bin/env if test ! -d /var/www/application/current; then echo "Directory does not exist '/var/www/application/current'" 1>&2; false; fi on 54.164.27.12
DEBUG[ad6525c4] Command: if test ! -d /var/www/application/current; then echo "Directory does not exist '/var/www/application/current'" 1>&2; false; fi
DEBUG[ad6525c4] Finished in 0.261 seconds with exit status 0 (successful).
INFO[948e14cf] Running RBENV_ROOT=/opt/rbenv RBENV_VERSION=2.1.1 /opt/rbenv/bin/rbenv exec bundle exec puma -C /var/www/application/shared/puma.rb --daemon on 54.164.27.12
DEBUG[948e14cf] Command: cd /var/www/application/current && ( PATH=~/.rbenv/shims:~/.rbenv/bin:$PATH RBENV_ROOT=/opt/rbenv RBENV_VERSION=2.1.1 RACK_ENV=staging RBENV_ROOT=/opt/rbenv RBENV_VERSION=2.1.1 /opt/rbenv/bin/rbenv exec bundle exec puma -C /var/www/application/shared/puma.rb --daemon )
This 2 cases produce a dashboard without communication with the background jobs. So widgets are empty.
Running Manually the Application Server Script
So if you ssh the box and manually run the same instruction to start the Application server:
For Unicorn:
PATH=~/.rbenv/shims:~/.rbenv/bin:$PATH RBENV_ROOT=/opt/rbenv RBENV_VERSION=2.1.1 RAILS_ENV=staging RBENV_ROOT=/opt/rbenv RBENV_VERSION=2.1.1 /opt/rbenv/bin/rbenv exec bundle exec unicorn -c /var/www/application/current/config/unicorn/config.rb -E deployment -D
For Puma:
PATH=~/.rbenv/shims:~/.rbenv/bin:$PATH RBENV_ROOT=/opt/rbenv RBENV_VERSION=2.1.1 RACK_ENV=staging RBENV_ROOT=/opt/rbenv RBENV_VERSION=2.1.1 /opt/rbenv/bin/rbenv exec bundle exec puma -C /var/www/application/shared/puma.rb
Makes things works:
Can someone help me to understand why executing the script between brackets "cd /..../current && ( bundle exec puma .... )" doesn't work with the events for Dashing? or catch the mystery.