forked from huginn/huginn
-
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.
- Loading branch information
1 parent
38e3dfb
commit b44616b
Showing
14 changed files
with
435 additions
and
2 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
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 @@ | ||
.DS_Store |
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,10 @@ | ||
#!/usr/bin/env ruby | ||
#^syntax detection | ||
|
||
site 'http://community.opscode.com/api/v1' | ||
|
||
cookbook 'runit' | ||
cookbook 'git', :git => 'git://github.com/opscode-cookbooks/git.git' | ||
cookbook 'nginx', :git => 'git://github.com/opscode-cookbooks/nginx.git' | ||
cookbook 'mysql', :git => 'git://github.com/opscode-cookbooks/mysql.git' | ||
cookbook 'nodejs', :git => 'git://github.com/mdxp/nodejs-cookbook.git' |
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,45 @@ | ||
Install librarian-chef gem | ||
|
||
gem install librarian-chef | ||
|
||
And Vagrant plugins | ||
|
||
vagrant plugin install vagrant-aws | ||
vagrant plugin install vagrant-omnibus | ||
|
||
Move to repo directory and run | ||
|
||
librarian-chef install | ||
|
||
This will install all the cookbooks mentioned in Cheffile. | ||
|
||
To install Huginn on AWS, fill the Vagrantfile with your account details and run | ||
|
||
vagrant up ec2 --provider=aws | ||
|
||
To install it on a virtualbox VM: | ||
|
||
vagrant up vb | ||
|
||
It'll install huginn and get the server started. You can now go to `yourserver.com/3000` to use huginn if you are in virtualbox. On ec2, pointing to public DNS will let you access huginn. Huginn will be at `/home/huginn/huginn`. A new dedicated user will be created for managing huginn with username `huginn` and password `huginn`. To ssh into ec2: | ||
|
||
vagrant ssh ec2 | ||
|
||
Similarly, to ssh into VirtualBox | ||
|
||
vagrant ssh vb | ||
|
||
After ssh-ing into ec2, you can start(its already running), stop or restart huginn by | ||
|
||
sudo start huginn | ||
sudo stop huginn | ||
sudo restart huginn | ||
|
||
To terminate ec2 instance: | ||
|
||
vagrant destroy ec2 | ||
|
||
Similarly, to destroy VirtualBox VM | ||
|
||
vagrant destroy vb | ||
|
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,63 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
Vagrant.configure("2") do |config| | ||
# Every Vagrant virtual environment requires a box to build off of. | ||
config.omnibus.chef_version = :latest | ||
config.vm.define :vb do |vb| | ||
# vagrant up vb | ||
vb.vm.box = "precise32" | ||
vb.vm.box_url = "http://files.vagrantup.com/precise32.box" | ||
vb.vm.network :forwarded_port, host: 3000, guest: 3000 | ||
|
||
vb.vm.provision :chef_solo do |chef| | ||
chef.roles_path = "roles" | ||
chef.cookbooks_path = ["cookbooks", "site-cookbooks"] | ||
chef.add_role("huginn_development") | ||
chef.json = { | ||
"mysql"=> { | ||
"server_root_password" => "", | ||
"server_repl_password" => "", | ||
"server_debian_password"=> "" | ||
}, | ||
"nginx" => { | ||
'init_style' => "upstart" | ||
} | ||
} | ||
end | ||
end | ||
|
||
config.vm.define :ec2 do |ec2| | ||
# vagrant plugin install vagrant-aws | ||
# vagrant plugin install vagrant-omnibus -- So as to make sure chef is installed on ec2 instance | ||
# vagrant up ec2 --provider=aws | ||
ec2.vm.box = "dummy" | ||
ec2.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box" | ||
|
||
ec2.vm.provider :aws do |aws, override| | ||
aws.access_key_id = "" | ||
aws.secret_access_key = "" | ||
aws.keypair_name = "" | ||
aws.region = "us-east-1" | ||
aws.ami = "ami-d0f89fb9" | ||
|
||
override.ssh.username = "ubuntu" | ||
override.ssh.private_key_path = "" | ||
end | ||
ec2.vm.provision :chef_solo do |chef| | ||
chef.roles_path = "roles" | ||
chef.cookbooks_path = ["cookbooks", "site-cookbooks"] | ||
chef.add_role("huginn_production") | ||
chef.json = { | ||
"mysql"=> { | ||
"server_root_password" => "", | ||
"server_repl_password" => "", | ||
"server_debian_password"=> "" | ||
}, | ||
"nginx" => { | ||
'init_style' => "upstart" | ||
} | ||
} | ||
end | ||
end | ||
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,18 @@ | ||
{ | ||
|
||
"name" : "huginn_development", | ||
|
||
"chef_type" : "role", | ||
|
||
"json_class" : "Chef::Role", | ||
|
||
"description" : "Huginn Development Environment", | ||
|
||
"run_list":[ | ||
"recipe[git]", | ||
"recipe[apt]", | ||
"recipe[mysql::server]", | ||
"recipe[nodejs::install_from_binary]", | ||
"recipe[huginn_development]" | ||
] | ||
} |
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,19 @@ | ||
{ | ||
|
||
"name" : "huginn_production", | ||
|
||
"chef_type" : "role", | ||
|
||
"json_class" : "Chef::Role", | ||
|
||
"description" : "Huginn Production Environment", | ||
|
||
"run_list":[ | ||
"recipe[git]", | ||
"recipe[apt]", | ||
"recipe[mysql::server]", | ||
"recipe[nodejs::install_from_binary]", | ||
"recipe[nginx]", | ||
"recipe[huginn_production]" | ||
] | ||
} |
44 changes: 44 additions & 0 deletions
44
deployment/site-cookbooks/huginn_development/recipes/default.rb
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,44 @@ | ||
include_recipe 'apt' | ||
include_recipe 'build-essential' | ||
|
||
%w("ruby1.9.1" "ruby1.9.1-dev" "libxslt-dev" "libxml2-dev" "curl").each do |pkg| | ||
package pkg do | ||
action :install | ||
end | ||
end | ||
|
||
git "/usr/local/huginn" do | ||
repository 'git://github.com/cantino/huginn.git' | ||
reference 'master' | ||
action :sync | ||
end | ||
|
||
gem_package("rake") | ||
gem_package("bundle") | ||
|
||
bash "huginn dependencies" do | ||
user "root" | ||
cwd "/usr/local/huginn" | ||
code <<-EOH | ||
export LANG="en_US.UTF-8" | ||
export LC_ALL="en_US.UTF-8" | ||
bundle install | ||
sed s/REPLACE_ME_NOW\!/$(rake secret)/ .env.example > .env | ||
rake db:create | ||
rake db:migrate | ||
rake db:seed | ||
EOH | ||
end | ||
|
||
#log "huginn start" do | ||
# level :info | ||
# message "Huginn has been installed and wil start at your instance in two minutes" | ||
#end | ||
|
||
bash "Huginn has been installed and server will start in a minute" do | ||
user "root" | ||
cwd "/usr/local/huginn" | ||
code <<-EOH | ||
sudo foreman start | ||
EOH | ||
end |
59 changes: 59 additions & 0 deletions
59
deployment/site-cookbooks/huginn_production/files/default/Gemfile
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 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'rails' | ||
gem 'rake' | ||
gem 'mysql2' | ||
gem 'devise' | ||
gem 'rails_admin' | ||
gem 'kaminari' | ||
gem 'bootstrap-kaminari-views' | ||
gem "rufus-scheduler", :require => false | ||
gem 'json', '>= 1.7.7' | ||
gem 'jsonpath' | ||
gem 'twilio-ruby' | ||
|
||
gem 'delayed_job', :git => 'https://github.com/wok/delayed_job' # Until the YAML issues are fixed in master. | ||
gem 'delayed_job_active_record', "~> 0.3.3" # newer was giving a strange MySQL error | ||
gem "daemons" | ||
# gem "delayed_job_web" | ||
group :production do | ||
gem 'unicorn' | ||
end | ||
gem 'foreman' | ||
gem 'dotenv-rails', :groups => [:development, :test] | ||
|
||
group :assets do | ||
gem 'sass-rails', '~> 3.2.3' | ||
gem 'coffee-rails', '~> 3.2.1' | ||
gem 'uglifier', '>= 1.0.3' | ||
gem 'select2-rails' | ||
gem 'jquery-rails' | ||
end | ||
|
||
gem 'geokit-rails3' | ||
gem 'kramdown' | ||
gem "typhoeus" | ||
gem 'nokogiri' | ||
gem 'wunderground' | ||
|
||
gem "twitter" | ||
gem 'twitter-stream', '>=0.1.16' | ||
gem 'em-http-request' | ||
|
||
platforms :ruby_18 do | ||
gem 'system_timer' | ||
gem 'fastercsv' | ||
end | ||
|
||
group :development do | ||
gem 'pry' | ||
end | ||
|
||
group :development, :test do | ||
gem 'rspec-rails' | ||
gem 'rspec' | ||
gem 'shoulda-matchers' | ||
gem 'rr' | ||
gem 'webmock', :require => false | ||
gem 'rake' | ||
end |
4 changes: 4 additions & 0 deletions
4
deployment/site-cookbooks/huginn_production/files/default/Procfile
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,4 @@ | ||
web: sudo bundle exec unicorn_rails -c config/unicorn.rb | ||
schedule: sudo bundle exec rails runner bin/schedule.rb | ||
twitter: sudo bundle exec rails runner bin/twitter_stream.rb | ||
dj: sudo bundle exec script/delayed_job run |
37 changes: 37 additions & 0 deletions
37
deployment/site-cookbooks/huginn_production/files/default/nginx.conf
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,37 @@ | ||
#worker_process 2; | ||
#user huginn huginn; | ||
|
||
events { | ||
worker_connections 1024; | ||
accept_mutex on; | ||
} | ||
|
||
http { | ||
upstream huginn_server { | ||
server unix:/home/huginn/huginn/tmp/sockets/unicorn.sock; | ||
} | ||
|
||
server { | ||
listen 80; | ||
server_name _; | ||
keepalive_timeout 5; | ||
root /home/huginn/huginn/public; | ||
try_files $uri/index.html $uri.html $uri @app; | ||
error_page 500 502 503 504 /500.html; | ||
location = /500.html { | ||
root /home/huginn/huginn/public; | ||
} | ||
location @app { | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
|
||
proxy_set_header X-Forwarded-Proto $scheme; | ||
|
||
proxy_set_header Host $http_host; | ||
|
||
proxy_redirect off; | ||
|
||
proxy_pass http://huginn_server; | ||
} | ||
} | ||
} | ||
|
33 changes: 33 additions & 0 deletions
33
deployment/site-cookbooks/huginn_production/files/default/unicorn.rb
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 @@ | ||
app_path = "/home/huginn/huginn" | ||
|
||
worker_processes 2 | ||
preload_app true | ||
timeout 180 | ||
listen '/home/huginn/huginn/tmp/sockets/unicorn.sock' | ||
|
||
working_directory app_path | ||
|
||
rails_env = ENV['RAILS_ENV'] || 'production' | ||
|
||
# Log everything to one file | ||
stderr_path "log/unicorn_out.log" | ||
stdout_path "log/unicorn_err.log" | ||
|
||
# Set master PID location | ||
pid '/home/huginn/huginn/tmp/pids/unicorn.pid' | ||
|
||
before_fork do |server, worker| | ||
ActiveRecord::Base.connection.disconnect! | ||
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 |
Oops, something went wrong.