forked from openaddresses/machine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'hooked-on-sources-master'
Conflicts: .gitignore .travis.yml chef/openaddr/recipes/default.rb openaddr/VERSION setup.py test.py
- Loading branch information
Showing
24 changed files
with
1,070 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ venv?-* | |
state-*.txt | ||
state-*.json | ||
env-* | ||
venv-hooked-on-sources |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
web: gunicorn -w 4 --bind 0.0.0.0:$PORT openaddr.ci:app | ||
dequeue: python -m openaddr.ci.run_dequeue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
worker: openaddr-ci-worker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name = node[:username] | ||
|
||
group name | ||
user name do | ||
gid name | ||
home "/home/#{name}" | ||
end | ||
|
||
directory "/home/#{name}" do | ||
owner name | ||
group name | ||
mode "0755" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package 'apache2' | ||
|
||
file '/etc/apache2/sites-available/webhook.conf' do | ||
content <<-CONF | ||
<VirtualHost *:80> | ||
<Location /> | ||
ProxyPass http://127.0.0.1:5000/ | ||
ProxyPassReverse http://127.0.0.1:5000/ | ||
</Location> | ||
<Proxy http://127.0.0.1:5000/*> | ||
Allow from all | ||
</Proxy> | ||
</VirtualHost> | ||
CONF | ||
end | ||
|
||
execute 'a2enmod proxy' | ||
execute 'a2enmod proxy_http' | ||
|
||
execute 'a2ensite webhook' | ||
execute 'a2dissite 000-default' | ||
|
||
execute 'service apache2 reload' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package 'postgresql' | ||
|
||
user = node[:db_user] | ||
pass = node[:db_pass] | ||
host = node[:db_host] | ||
name = node[:db_name] | ||
database_url = "postgres://#{user}:#{pass}@#{host}/#{name}?sslmode=require" | ||
|
||
if host == 'localhost' then | ||
args = '' | ||
else | ||
args = "-h '#{host}'" | ||
end | ||
|
||
bash "create database" do | ||
user 'postgres' | ||
environment({'DATABASE_URL' => database_url, 'GITHUB_TOKEN' => ''}) | ||
code <<-CODE | ||
# psql #{args} -c "DROP DATABASE IF EXISTS #{name}"; | ||
# psql #{args} -c "DROP USER IF EXISTS #{user}"; | ||
psql #{args} -c "CREATE USER #{user} WITH SUPERUSER PASSWORD '#{pass}'"; | ||
psql #{args} -c "CREATE DATABASE #{name} WITH OWNER #{user}"; | ||
openaddr-ci-recreate-db | ||
CODE | ||
|
||
# Stop as soon as an error is encountered. | ||
flags '-e' | ||
|
||
# Assume that exit=1 means the user and database were already in-place. | ||
returns [0, 1] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"db_user": "openaddr", | ||
"db_pass": "openaddr", | ||
"db_host": "localhost", | ||
"db_name": "openaddr", | ||
"run_list": | ||
[ | ||
"openaddr", | ||
"database" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"username": "openaddr", | ||
"db_user": "openaddr", | ||
"db_pass": "openaddr", | ||
"db_host": "localhost", | ||
"db_name": "openaddr", | ||
"github_token": "fake-token", | ||
"run_list": | ||
[ | ||
"openaddr", | ||
"database", | ||
"account", | ||
"webhooks", | ||
"sources" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"username": "openaddr", | ||
"db_user": "openaddr", | ||
"db_pass": "openaddr", | ||
"db_host": "localhost", | ||
"db_name": "openaddr", | ||
"github_token": "{Github Token}", | ||
"run_list": | ||
[ | ||
"openaddr", | ||
"account", | ||
"webhooks", | ||
"apache" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"username": "openaddr", | ||
"db_user": "openaddr", | ||
"db_pass": "openaddr", | ||
"db_host": "localhost", | ||
"db_name": "openaddr", | ||
"github_token": "{Github Token}", | ||
"run_list": | ||
[ | ||
"openaddr", | ||
"account", | ||
"worker" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
username = node[:username] | ||
app_name = 'openaddr_webhook' | ||
|
||
db_user = node[:db_user] | ||
db_pass = node[:db_pass] | ||
db_host = node[:db_host] | ||
db_name = node[:db_name] | ||
|
||
database_url = "postgres://#{db_user}:#{db_pass}@#{db_host}/#{db_name}?sslmode=require" | ||
github_token = node['github_token'] | ||
|
||
env_file = "/etc/#{app_name}.conf" | ||
procfile = File.join(File.dirname(__FILE__), '..', '..', 'Procfile-webhook') | ||
|
||
execute 'pip install honcho[export]' | ||
|
||
# | ||
# Ensure upstart job exists. | ||
# | ||
file env_file do | ||
content <<-CONF | ||
DATABASE_URL=#{database_url} | ||
GITHUB_TOKEN=#{github_token} | ||
CONF | ||
end | ||
|
||
execute "honcho export upstart /etc/init" do | ||
command "honcho -e #{env_file} -f #{procfile} export -u #{username} -a #{app_name} upstart /etc/init" | ||
end | ||
|
||
rotation = <<-ROTATION | ||
{ | ||
copytruncate | ||
rotate 4 | ||
weekly | ||
missingok | ||
notifempty | ||
compress | ||
delaycompress | ||
endscript | ||
} | ||
ROTATION | ||
|
||
file "/etc/logrotate.d/#{app_name}-web-1" do | ||
content "/var/log/#{app_name}/web-1.log\n#{rotation}\n" | ||
end | ||
|
||
file "/etc/logrotate.d/#{app_name}-dequeue-1" do | ||
content "/var/log/#{app_name}/dequeue-1.log\n#{rotation}\n" | ||
end | ||
|
||
# | ||
# Make it go. | ||
# | ||
execute "stop #{app_name}" do | ||
returns [0, 1] | ||
end | ||
|
||
execute "start #{app_name}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
username = node[:username] | ||
app_name = 'openaddr_worker' | ||
|
||
db_user = node[:db_user] | ||
db_pass = node[:db_pass] | ||
db_host = node[:db_host] | ||
db_name = node[:db_name] | ||
|
||
database_url = "postgres://#{db_user}:#{db_pass}@#{db_host}/#{db_name}?sslmode=require" | ||
github_token = node['github_token'] | ||
|
||
env_file = "/etc/#{app_name}.conf" | ||
procfile = File.join(File.dirname(__FILE__), '..', '..', 'Procfile-worker') | ||
|
||
execute 'pip install honcho[export]' | ||
|
||
# | ||
# Ensure upstart job exists. | ||
# | ||
file env_file do | ||
content <<-CONF | ||
DATABASE_URL=#{database_url} | ||
GITHUB_TOKEN=#{github_token} | ||
CONF | ||
end | ||
|
||
execute "honcho export upstart /etc/init" do | ||
command "honcho -e #{env_file} -f #{procfile} export -u #{username} -a #{app_name} upstart /etc/init" | ||
end | ||
|
||
rotation = <<-ROTATION | ||
{ | ||
copytruncate | ||
rotate 4 | ||
weekly | ||
missingok | ||
notifempty | ||
compress | ||
delaycompress | ||
endscript | ||
} | ||
ROTATION | ||
|
||
file "/etc/logrotate.d/#{app_name}-worker-1" do | ||
content "/var/log/#{app_name}/worker-1.log\n#{rotation}\n" | ||
end | ||
|
||
# | ||
# Make it go. | ||
# | ||
execute "stop #{app_name}" do | ||
returns [0, 1] | ||
end | ||
|
||
execute "start #{app_name}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.7.1 | ||
1.7.1 |
Oops, something went wrong.