Skip to content

Instantly share code, notes, and snippets.

@stansidel
Last active August 29, 2015 13:56
Show Gist options
  • Save stansidel/8845359 to your computer and use it in GitHub Desktop.
Save stansidel/8845359 to your computer and use it in GitHub Desktop.
An error on vagrant when using intercity/chef-repo
Recipe: bluepill::default
* gem_package[i18n] action install (up to date)
* gem_package[bluepill] action install
- install version 0.0.66 of package bluepill
* directory[/etc/bluepill] action create
- create new directory /etc/bluepill
- change owner from '' to 'root'
- change group from '' to '0'
* directory[/var/run/bluepill] action create
- create new directory /var/run/bluepill
- change owner from '' to 'root'
- change group from '' to '0'
* directory[/var/lib/bluepill] action create
- create new directory /var/lib/bluepill
- change owner from '' to 'root'
- change group from '' to '0'
* file[/var/log/bluepill.log] action create_if_missing
- create new file /var/log/bluepill.log
- change mode from '' to '0755'
- change owner from '' to 'root'
- change group from '' to '0'
...
Recipe: rails::default
* rbenv_ruby[2.1.0] action install
* rbenv_gem[bundler] action install
- install version 1.5.3 of package bundler
* directory[/u/apps/dapteka_staging] action create
- create new directory /u/apps/dapteka_staging
- change owner from '' to 'deploy'
- change group from '' to 'deploy'
* directory[/u/apps/dapteka_staging/config] action create
- create new directory /u/apps/dapteka_staging/config
- change owner from '' to 'deploy'
- change group from '' to 'deploy'
* directory[/u/apps/dapteka_staging/shared] action create
- create new directory /u/apps/dapteka_staging/shared
- change owner from '' to 'deploy'
- change group from '' to 'deploy'
* directory[/u/apps/dapteka_staging/shared/config] action create
- create new directory /u/apps/dapteka_staging/shared/config
- change owner from '' to 'deploy'
- change group from '' to 'deploy'
* directory[/u/apps/dapteka_staging/shared/sockets] action create
- create new directory /u/apps/dapteka_staging/shared/sockets
- change owner from '' to 'deploy'
- change group from '' to 'deploy'
* directory[/u/apps/dapteka_staging/shared/pids] action create
- create new directory /u/apps/dapteka_staging/shared/pids
- change owner from '' to 'deploy'
- change group from '' to 'deploy'
* directory[/u/apps/dapteka_staging/shared/log] action create
- create new directory /u/apps/dapteka_staging/shared/log
- change owner from '' to 'deploy'
- change group from '' to 'deploy'
* directory[/u/apps/dapteka_staging/shared/system] action create
- create new directory /u/apps/dapteka_staging/shared/system
- change owner from '' to 'deploy'
- change group from '' to 'deploy'
* directory[/u/apps/dapteka_staging/releases] action create
- create new directory /u/apps/dapteka_staging/releases
- change owner from '' to 'deploy'
- change group from '' to 'deploy'
* template[/u/apps/dapteka_staging/shared/config/database.yml] action create
- create new file /u/apps/dapteka_staging/shared/config/database.yml
- update content in file /u/apps/dapteka_staging/shared/config/database.yml from none to 78dc52
--- /u/apps/dapteka_staging/shared/config/database.yml 2014-02-06 14:19:00.828655291 +0000
+++ /tmp/chef-rendered-template20140206-4262-1waw2wr 2014-02-06 14:19:00.832657291 +0000
@@ -1 +1,10 @@
+production:
+ adapter: mysql2
+ host: localhost
+ username: dapteka
+ password: scsIDfs(#2sd
+ pool: 5
+ timeout: 5000
+ database: dapteka_production
+ encoding: utf8
- change mode from '' to '0600'
- change owner from '' to 'deploy'
- change group from '' to 'deploy'
* template[/etc/nginx/sites-available/dapteka_staging.conf] action create
- create new file /etc/nginx/sites-available/dapteka_staging.conf
- update content in file /etc/nginx/sites-available/dapteka_staging.conf from none to 9165cd
--- /etc/nginx/sites-available/dapteka_staging.conf 2014-02-06 14:19:00.880681290 +0000
+++ /tmp/chef-rendered-template20140206-4262-5ptsnd 2014-02-06 14:19:00.884683290 +0000
@@ -1 +1,22 @@
+server {
+ listen 80;
+ server_name local.d-apteka.ru;
+ root /u/apps/dapteka_staging/current/public;
+
+ try_files $uri/index.html $uri.html $uri @app;
+
+ location @app {
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header Host $http_host;
+ proxy_redirect off;
+
+ proxy_pass http://dapteka_staging;
+ }
+
+}
+
+
+upstream dapteka_staging {
+ server unix:/u/apps/dapteka_staging/shared/sockets/unicorn.sock;
+}
* template[/u/apps/dapteka_staging/shared/config/unicorn.rb] action create
- create new file /u/apps/dapteka_staging/shared/config/unicorn.rb
- update content in file /u/apps/dapteka_staging/shared/config/unicorn.rb from none to af76e1
--- /u/apps/dapteka_staging/shared/config/unicorn.rb 2014-02-06 14:19:00.896689289 +0000
+++ /tmp/chef-rendered-template20140206-4262-er4gv6 2014-02-06 14:19:00.896689289 +0000
@@ -1 +1,52 @@
+# ------------------------------------------------------------------------------
+# Sample rails 3 config
+# ------------------------------------------------------------------------------
+
+# Set your full path to application.
+app_path = "/u/apps/dapteka_staging"
+
+# Set unicorn options
+worker_processes 2
+preload_app true
+timeout 30
+listen "#{app_path}/shared/sockets/unicorn.sock", :backlog => 2048
+
+# Spawn unicorn master worker for user apps (group: apps)
+user 'deploy', 'deploy'
+
+# Fill path to your app
+working_directory "#{app_path}/current"
+
+# Should be 'production' by default, otherwise use other env
+rails_env = ENV['RAILS_ENV'] || 'production'
+
+# Log everything to one file
+stderr_path "log/unicorn.log"
+stdout_path "log/unicorn.log"
+
+# Set master PID location
+pid "#{app_path}/shared/pids/unicorn.pid"
+
+before_exec do |server|
+ ENV["BUNDLE_GEMFILE"] = "#{app_path}/current/Gemfile"
+end
+
+before_fork do |server, worker|
+ ActiveRecord::Base.connection.disconnect!
+
+ sleep 10
+
+ old_pid = "#{server.config[:pid]}.oldbin"
+ if File.exists?(old_pid) && server.pid != old_pid
+ begin
+ Process.kill("QUIT", File.read(old_pid).to_i)
+ rescue Errno::ENOENT, Errno::ESRCH
+ # someone else did our job for us
+ end
+ end
+end
+
+after_fork do |server, worker|
+ ActiveRecord::Base.establish_connection
+end
- change mode from '' to '0644'
* template[/etc/bluepill/dapteka_staging.pill] action create
- create new file /etc/bluepill/dapteka_staging.pill
- update content in file /etc/bluepill/dapteka_staging.pill from none to bb9293
--- /etc/bluepill/dapteka_staging.pill 2014-02-06 14:19:00.912697289 +0000
+++ /tmp/chef-rendered-template20140206-4262-18zkgpu 2014-02-06 14:19:00.912697289 +0000
@@ -1 +1,27 @@
+Bluepill.application("dapteka_staging", :log_file => "/u/apps/dapteka_staging/shared/log/bluepill.log") do |app|
+ app.working_dir = "/u/apps/dapteka_staging/current"
+ app.environment = {"RAILS_ENV" => "production" }
+ app.process("dapteka_staging") do |process|
+ process.start_command = "/bin/bash --login -c '/u/apps/dapteka_staging/current/bin/unicorn /u/apps/dapteka_staging/current/config.ru -Dc /u/apps/dapteka_staging/shared/config/unicorn.rb -E production'"
+ process.stop_command = "kill -QUIT {{PID}}"
+ process.restart_command = "kill -USR2 {{PID}}"
+ process.stdout = process.stderr = "/u/apps/dapteka_staging/shared/log/unicorn.log"
+ process.pid_file = "/u/apps/dapteka_staging/shared/pids/unicorn.pid"
+
+ process.checks :mem_usage, :every => 1.minute, :below => 130.megabytes, :times => [3, 5]
+
+ process.uid = "deploy"
+ process.gid = "deploy"
+
+ process.start_grace_time = 1.minute
+ process.restart_grace_time = 1.minute
+
+ process.checks :flapping, :times => 2, :within => 30.seconds, :retry_in => 7.seconds
+
+ process.monitor_children do |cp|
+ cp.checks :mem_usage, :every => 1.minute, :below => 130.megabytes, :times => [3, 5]
+ cp.stop_command = "kill -QUIT {{PID}}"
+ end
+ end
+end
- change mode from '' to '0644'
* bluepill_service[dapteka_staging] action enable
- enable bluepill_service[dapteka_staging]
* bluepill_service[dapteka_staging] action load
================================================================================
Error executing action `load` on resource 'bluepill_service[dapteka_staging]'
================================================================================
Errno::ENOENT
-------------
No such file or directory - /usr/bin/bluepill load /etc/bluepill/dapteka_staging.pill
Cookbook Trace:
---------------
/root/chef-solo/cookbooks-2/bluepill/providers/service.rb:64:in `block (2 levels) in class_from_file'
/root/chef-solo/cookbooks-2/bluepill/providers/service.rb:63:in `block in class_from_file'
Resource Declaration:
---------------------
# In /root/chef-solo/cookbooks-2/rails/recipes/default.rb
147: bluepill_service app do
148: action [:enable, :load, :start]
149: end
150:
Compiled Resource:
------------------
# Declared in /root/chef-solo/cookbooks-2/rails/recipes/default.rb:147:in `block in from_file'
bluepill_service("dapteka_staging") do
action [:enable, :load, :start]
updated true
retries 0
retry_delay 2
cookbook_name :rails
recipe_name "default"
service_name "dapteka_staging"
end
Recipe: mysql::server
* service[mysql] action restart
- restart service service[mysql]
Recipe: nginx::default
* service[nginx] action reload
- reload service service[nginx]
[2014-02-06T14:19:04+00:00] ERROR: Running exception handlers
[2014-02-06T14:19:04+00:00] ERROR: Exception handlers complete
[2014-02-06T14:19:04+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 91 resources updated
[2014-02-06T14:19:04+00:00] ERROR: bluepill_service[dapteka_staging] (rails::default line 147) had an error: Errno::ENOENT: No such file or directory - /usr/bin/bluepill load /etc/bluepill/dapteka_staging.pill
[2014-02-06T14:19:04+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
ERROR: RuntimeError: chef-solo failed. See output above.
@stansidel
Copy link
Author

Refs: Opscode 1794 and Chef-repo issue #24.

A workaround for this issue (actually, it's reproducible on vagrant with Ubuntu 13 and above only) is to add "bluepill": { "bin": "/usr/local/bin/bluepill" } to your node config. It could look like this:

{
  "run_list":["role[mysql]","role[rails_passenger]"],
  "bluepill": { "bin": "/usr/local/bin/bluepill" },
  "mysql": {
    "server_debian_password": "<enter a random password>",
    "server_root_password": "<enter a random password>",
    "server_repl_password": "<enter a random password>"
  },
  #...
}

It's tested on vagrant with Ubuntu 14.04 amd64.

PS Also don't forget to provide the VM with 1.5Gb+ RAM (physical or swap), otherwise there would be errors with the mysql-server installation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment