Skip to content

Commit

Permalink
Lot of fixes in cabot
Browse files Browse the repository at this point in the history
  • Loading branch information
bpaquet committed May 6, 2015
1 parent 7211ffd commit c8c7f6e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
12 changes: 10 additions & 2 deletions cookbooks/cabot/attributes/default.rb
@@ -1,7 +1,7 @@
default[:cabot][:root] = "/opt/cabot"

default[:cabot][:git] = "https://github.com/arachnys/cabot.git"
default[:cabot][:version] = "2708ee7eed7dd5199f84a4f491ebe0c243870354"
default[:cabot][:git] = "https://github.com/doctolib/cabot.git"
default[:cabot][:version] = "0539beda938aebd1a3947c42da1322597be99e26"

default[:cabot][:user] = "cabot"

Expand All @@ -26,6 +26,14 @@
:smtp_port => 123,
:cabot_host => "http://cabot.example.com",
:scheme => "http",
:alert_interval => "60", # minutes
:notification_interval => "60", # minutes
}

default[:cabot][:plugins] = {
'cabot_alert_hipchat' => '1.6.1',
'cabot_alert_email' => 'git+https://git@github.com/doctolib/cabot-alert-email.git@22f28d9f290e5e161716cc6691f412330a566a19#egg=cabot_alert_email-1.3.166',
'cabot_alert_twilio' => '1.1.4',
}

default[:cabot][:nginx][:cabot] = {
Expand Down
28 changes: 16 additions & 12 deletions cookbooks/cabot/recipes/default.rb
@@ -1,4 +1,6 @@

require 'digest'

node.set[:postgresql][:databases][:cabot] = {
:host => 'localhost',
:database => 'cabot',
Expand Down Expand Up @@ -40,6 +42,7 @@
repository node.cabot.git
reference node.cabot.version
user node.cabot.user
notifies :restart, "service[#{node.supervisor.service_name}]"
end

execute "create cabot virtual env" do
Expand All @@ -48,17 +51,17 @@
not_if "[ -d #{node.cabot.root}/venv ]"
end

execute_version "install cabot dependencies" do
command "cd #{node.cabot.root}/current && . #{node.cabot.root}/venv/bin/activate && pip install -e ."
user "cabot"
file_storage "#{node.cabot.root}/.dependencies"
version node.cabot.version
end

django_secret_key = local_storage_read("cabot:django_secret_key") do
PasswordGenerator.generate 64
end

template "#{node.cabot.root}/shared/run.sh" do
owner "cabot"
source "run.sh.erb"
mode "0755"
variables :root => node.cabot.root, :virtual_env => "#{node.cabot.root}/venv"
end

template "#{node.cabot.root}/shared/production.env" do
owner "cabot"
source "production.env.erb"
Expand All @@ -69,15 +72,16 @@
:port => node.cabot.port,
:extra_config => node.cabot.extra_config,
:django_secret_key => django_secret_key,
:plugins => node.cabot.plugins,
})
notifies :restart, "service[#{node.supervisor.service_name}]"
end

template "#{node.cabot.root}/shared/run.sh" do
owner "cabot"
source "run.sh.erb"
mode "0755"
variables :root => node.cabot.root, :virtual_env => "#{node.cabot.root}/venv"
execute_version "install cabot dependencies" do
command "cd #{node.cabot.root}/current && . #{node.cabot.root}/venv/bin/activate && /opt/cabot/shared/run.sh pip install --process-dependency-links -e ."
user "cabot"
file_storage "#{node.cabot.root}/.dependencies"
version node.cabot.version + '_' + Digest::MD5.hexdigest(SortedJsonDump.pretty_generate(node.cabot.plugins.to_hash))
end

[
Expand Down
6 changes: 5 additions & 1 deletion cookbooks/cabot/templates/default/production.env.erb
@@ -1,7 +1,8 @@

# Plugins to be loaded at launch
# CABOT_PLUGINS_ENABLED=cabot_alert_hipchat,cabot_alert_twilio,cabot_alert_email
export CABOT_PLUGINS_ENABLED=cabot_alert_hipchat==1.6.1,cabot_alert_email==1.3.1,cabot_alert_twilio==1.1.4
export CABOT_PLUGINS_ENABLED=<%= @plugins.keys.sort.map{|k| "#{k}==#{@plugins[k].split('-').last}"}.join(',') %>
export CABOT_PLUGINS_LINKS_ENABLED=<%= @plugins.keys.sort.map{|k| "#{k}==#{@plugins[k]}"}.select{|x| x.match(/git/)}.map{|x| x.split('==').last}.join(',') %>

export DATABASE_URL=postgres://<%= @database["username"] %>:<%= @password %>@<%= @database["host"] %>:5432/<%= @database["database"] %>

Expand Down Expand Up @@ -59,3 +60,6 @@ export TWILIO_OUTGOING_NUMBER=+14155551234
# Used for pointing links back in alerts etc.
export WWW_HTTP_HOST=<%= @extra_config["cabot_host"] %>
export WWW_SCHEME=<%= @extra_config["scheme"] %>

export ALERT_INTERVAL=<%= @extra_config["alert_interval"] %>
export NOTIFICATION_INTERVAL=<%= @extra_config["notification_interval"] %>

0 comments on commit c8c7f6e

Please sign in to comment.