@@ -1,6 +1,37 @@ |
||
1 |
+# ==== Required configuration settings for Huginn ==== |
|
2 |
+ |
|
3 |
+# Replace the following with the output from "rake secret" |
|
1 | 4 |
APP_SECRET_TOKEN=REPLACE_ME_NOW! |
5 |
+ |
|
6 |
+# This is the domain where your Huginn instance will be running. The default should work |
|
7 |
+# for development, but it needs to be changed when you deploy to a production environment. |
|
2 | 8 |
DOMAIN=localhost:3000 |
3 |
-GOOGLE_APPS_DOMAIN=your-domain-here.com |
|
4 |
-GMAIL_USERNAME=you@gmail.com |
|
5 |
-GMAIL_PASSWORD=somepassword |
|
6 |
-EMAIL_FROM_ADDRESS=from_address@gmail.com |
|
9 |
+ |
|
10 |
+# Database Setup |
|
11 |
+DATABASE_ADAPTER=mysql2 |
|
12 |
+DATABASE_ENCODING=utf8 |
|
13 |
+DATABASE_RECONNECT=true |
|
14 |
+DATABASE_NAME=huginn_development |
|
15 |
+DATABASE_POOL=5 |
|
16 |
+DATABASE_USERNAME=root |
|
17 |
+DATABASE_PASSWORD= |
|
18 |
+DATABASE_SOCKET=/tmp/mysql.sock |
|
19 |
+ |
|
20 |
+# ==== Additional required production settings ==== |
|
21 |
+ |
|
22 |
+# Outgoing email settings. To use Gmail or Google Apps, put your Google Apps domain or gmail.com |
|
23 |
+# as the SMTP_DOMAIN and your Gmail username and password as the SMTP_USER_NAME and SMTP_PASSWORD. |
|
24 |
+SMTP_DOMAIN=your-domain-here.com |
|
25 |
+SMTP_USER_NAME=you@gmail.com |
|
26 |
+SMTP_PASSWORD=somepassword |
|
27 |
+SMTP_SERVER=smtp.gmail.com |
|
28 |
+SMTP_PORT=587 |
|
29 |
+SMTP_AUTHENTICATION=plain |
|
30 |
+SMTP_ENABLE_STARTTLS_AUTO=true |
|
31 |
+ |
|
32 |
+# The address from which system emails will appear to be sent. |
|
33 |
+EMAIL_FROM_ADDRESS=from_address@gmail.com |
|
34 |
+ |
|
35 |
+# This invitation code will be required for users to signup with your Huginn installation. |
|
36 |
+# You can see its use in user.rb. |
|
37 |
+INVITATION_CODE=try-huginn |
@@ -40,14 +40,7 @@ platforms :ruby_18 do |
||
40 | 40 |
gem 'fastercsv' |
41 | 41 |
end |
42 | 42 |
|
43 |
-group :production do |
|
44 |
- gem 'unicorn' |
|
45 |
-end |
|
46 |
- |
|
47 | 43 |
group :development do |
48 |
- gem 'capistrano' |
|
49 |
- gem 'capistrano-unicorn', :require => false |
|
50 |
- gem 'rvm-capistrano' |
|
51 | 44 |
gem 'pry' |
52 | 45 |
end |
53 | 46 |
|
@@ -44,14 +44,6 @@ GEM |
||
44 | 44 |
bootstrap-sass (2.3.0.1) |
45 | 45 |
sass (~> 3.2) |
46 | 46 |
builder (3.0.4) |
47 |
- capistrano (2.14.2) |
|
48 |
- highline |
|
49 |
- net-scp (>= 1.0.0) |
|
50 |
- net-sftp (>= 2.0.0) |
|
51 |
- net-ssh (>= 2.0.14) |
|
52 |
- net-ssh-gateway (>= 1.1.0) |
|
53 |
- capistrano-unicorn (0.1.6) |
|
54 |
- capistrano |
|
55 | 47 |
coderay (1.0.9) |
56 | 48 |
coffee-rails (3.2.2) |
57 | 49 |
coffee-script (>= 2.2.0) |
@@ -103,7 +95,6 @@ GEM |
||
103 | 95 |
rails (~> 3.0) |
104 | 96 |
haml (4.0.0) |
105 | 97 |
tilt |
106 |
- highline (1.6.15) |
|
107 | 98 |
hike (1.2.1) |
108 | 99 |
http_parser.rb (0.5.3) |
109 | 100 |
httparty (0.10.2) |
@@ -123,7 +114,6 @@ GEM |
||
123 | 114 |
kaminari (0.14.1) |
124 | 115 |
actionpack (>= 3.0.0) |
125 | 116 |
activesupport (>= 3.0.0) |
126 |
- kgio (2.8.0) |
|
127 | 117 |
kramdown (0.14.2) |
128 | 118 |
mail (2.4.4) |
129 | 119 |
i18n (>= 0.4.0) |
@@ -136,13 +126,6 @@ GEM |
||
136 | 126 |
multipart-post (1.2.0) |
137 | 127 |
mysql2 (0.3.11) |
138 | 128 |
nested_form (0.3.1) |
139 |
- net-scp (1.0.4) |
|
140 |
- net-ssh (>= 1.99.1) |
|
141 |
- net-sftp (2.1.1) |
|
142 |
- net-ssh (>= 2.6.5) |
|
143 |
- net-ssh (2.6.6) |
|
144 |
- net-ssh-gateway (1.2.0) |
|
145 |
- net-ssh (>= 2.6.5) |
|
146 | 129 |
nokogiri (1.5.6) |
147 | 130 |
orm_adapter (0.4.0) |
148 | 131 |
polyglot (0.3.3) |
@@ -190,7 +173,6 @@ GEM |
||
190 | 173 |
rake (>= 0.8.7) |
191 | 174 |
rdoc (~> 3.4) |
192 | 175 |
thor (>= 0.14.6, < 2.0) |
193 |
- raindrops (0.10.0) |
|
194 | 176 |
rake (10.0.3) |
195 | 177 |
rdoc (3.12.2) |
196 | 178 |
json (~> 1.4) |
@@ -213,8 +195,6 @@ GEM |
||
213 | 195 |
rspec-mocks (~> 2.13.0) |
214 | 196 |
rufus-scheduler (2.0.18) |
215 | 197 |
tzinfo (>= 0.3.23) |
216 |
- rvm-capistrano (1.2.7) |
|
217 |
- capistrano (>= 2.0.0) |
|
218 | 198 |
safe_yaml (0.8.4) |
219 | 199 |
sass (3.2.7) |
220 | 200 |
sass-rails (3.2.6) |
@@ -251,10 +231,6 @@ GEM |
||
251 | 231 |
uglifier (1.3.0) |
252 | 232 |
execjs (>= 0.3.0) |
253 | 233 |
multi_json (~> 1.0, >= 1.0.2) |
254 |
- unicorn (4.6.2) |
|
255 |
- kgio (~> 2.6) |
|
256 |
- rack |
|
257 |
- raindrops (~> 0.7) |
|
258 | 234 |
warden (1.2.1) |
259 | 235 |
rack (>= 1.0) |
260 | 236 |
webmock (1.11.0) |
@@ -270,8 +246,6 @@ PLATFORMS |
||
270 | 246 |
|
271 | 247 |
DEPENDENCIES |
272 | 248 |
bootstrap-kaminari-views |
273 |
- capistrano |
|
274 |
- capistrano-unicorn |
|
275 | 249 |
coffee-rails (~> 3.2.1) |
276 | 250 |
daemons |
277 | 251 |
delayed_job! |
@@ -296,7 +270,6 @@ DEPENDENCIES |
||
296 | 270 |
rspec |
297 | 271 |
rspec-rails |
298 | 272 |
rufus-scheduler |
299 |
- rvm-capistrano |
|
300 | 273 |
sass-rails (~> 3.2.3) |
301 | 274 |
select2-rails |
302 | 275 |
system_timer |
@@ -304,6 +277,5 @@ DEPENDENCIES |
||
304 | 277 |
twitter-stream (>= 0.1.16) |
305 | 278 |
typhoeus |
306 | 279 |
uglifier (>= 1.0.3) |
307 |
- unicorn |
|
308 | 280 |
webmock |
309 | 281 |
wunderground |
@@ -39,12 +39,9 @@ And now, some example screenshots. Below them are instructions to get you start |
||
39 | 39 |
|
40 | 40 |
If you just want to play around, you can simply clone this repository, then perform the following steps: |
41 | 41 |
|
42 |
-* Copy .env.example to .env `cp .env.example .env` |
|
43 |
-* Edit the configuration options in .env |
|
44 |
-* Edit the APP_SECRET_TOKEN environment variable and replace `REPLACE_ME_NOW!` with the output of `rake secret`. |
|
42 |
+* Copy `.env.example` to `.env` (`cp .env.example .env`) and edit `.env`, at least updating the `APP_SECRET_TOKEN` variable. |
|
45 | 43 |
* Run `rake db:create`, `rake db:migrate`, and then `rake db:seed` to create a development MySQL database with some example seed data. |
46 | 44 |
* Run `foreman start`, visit `http://localhost:5000`, and login with the username of `admin` and the password of `password`. |
47 |
-* Make some extra Terminal windows and run `bundle exec rails runner bin/schedule.rb`, `bundle exec rails runner bin/twitter_stream.rb`, and `script/delayed_job run` in separate windows. |
|
48 | 45 |
* Setup some Agents! |
49 | 46 |
|
50 | 47 |
### Real Start |
@@ -70,26 +67,7 @@ Follow these instructions if you wish to deploy your own version of Huginn or co |
||
70 | 67 |
|
71 | 68 |
## Deployment |
72 | 69 |
|
73 |
-Deployment right now is configured with Capistrano, Unicorn, and nginx. You should feel free to deploy in a different way, however, and please submit your deployment solutions back! |
|
74 |
- |
|
75 |
-### Required Setup |
|
76 |
- |
|
77 |
-In your private copy of Huginn, do the following: |
|
78 |
- |
|
79 |
-* Edit `app/models/user.rb` and change the invitation code(s) in `INVITATION_CODES`. This controls who can signup to use your installation. |
|
80 |
-* Edit `app/mailers/system_mailer.rb` and set your default from address. |
|
81 |
-* Edit `config/environments/production.rb` and change the value of `DOMAIN` and the `config.action_mailer.smtp_settings` setup, which is currently setup for sending email through a Google Apps account on Gmail. |
|
82 |
-* Setup a place for Huginn to run. I recommend making a dedicated user on your server for Huginn, but this is not required. Setup nginx or Apache to proxy pass to unicorn. There is an example nginx script in `config/nginx/production.conf`. |
|
83 |
-* Setup a production MySQL database for your installation. |
|
84 |
-* Edit `config/unicorn/production.rb` and replace instances of *you* with the correct username for your server. |
|
85 |
-* Edit `config/deploy.rb` and change all instances of `you` and `yourdomain` to the appropriate values for your server setup. If you want RVM to be used and installed, uncomment the appropriate lines. Then, run `cap deploy:setup` followed by `cap deploy`. If everything goes well, this should start some unicorn workers on your server to run the Huginn web app. |
|
86 |
-* After deploying with capistrano, SSH into your server, go to the deployment directory, and run `RAILS_ENV=production bundle exec rake db:seed` to generate your admin user. Immediately login to your new Huginn installation with the username of `admin` and the password of `password` and change your email and password! |
|
87 |
-* You'll need to run bin/schedule.rb and bin/twitter_stream.rb in a daemonized way. I've just been using screen sessions, but please contribute something better! |
|
88 |
- |
|
89 |
- |
|
90 |
- RAILS_ENV=production bundle exec rails runner bin/schedule.rb |
|
91 |
- RAILS_ENV=production bundle exec rails runner bin/twitter_stream.rb |
|
92 |
- |
|
70 |
+Please see [the Huginn Wiki](https://github.com/cantino/huginn/wiki#deploying-huginn) for detailed deployment strategies for different providers. |
|
93 | 71 |
|
94 | 72 |
### Optional Setup |
95 | 73 |
|
@@ -111,10 +89,6 @@ You can use [Post Location](https://github.com/cantino/post_location) on your iP |
||
111 | 89 |
|
112 | 90 |
We assume your deployment will run over SSL. This is a very good idea! However, if you wish to turn this off, you'll probably need to edit `config/initializers/devise.rb` and modify the line containing `config.rememberable_options = { :secure => true }`. You will also need to edit `config/environments/production.rb` and modify the value of `config.force_ssl`. |
113 | 91 |
|
114 |
-#### Setup Backups |
|
115 |
- |
|
116 |
-Checkout `config/example_backup.rb` for an example script that you can use with the Backup gem. |
|
117 |
- |
|
118 | 92 |
## License |
119 | 93 |
|
120 | 94 |
Huginn is provided under the MIT License. |
@@ -5,7 +5,7 @@ class User < ActiveRecord::Base |
||
5 | 5 |
devise :database_authenticatable, :registerable, |
6 | 6 |
:recoverable, :rememberable, :trackable, :validatable, :lockable |
7 | 7 |
|
8 |
- INVITATION_CODES = %w[try-huginn] |
|
8 |
+ INVITATION_CODES = [ENV['INVITATION_CODE'] || 'try-huginn'] |
|
9 | 9 |
|
10 | 10 |
# Virtual attribute for authenticating by either username or email |
11 | 11 |
# This is in addition to a real persisted field like 'username' |
@@ -1,12 +1,12 @@ |
||
1 | 1 |
development: |
2 |
- adapter: mysql2 |
|
3 |
- database: huginn_development |
|
4 |
- username: root |
|
5 |
- password: |
|
6 |
- socket: <%= ["/var/run/mysqld/mysqld.sock", "/opt/local/var/run/mysql5/mysqld.sock", "/tmp/mysql.sock"].find{ |path| File.exist? path } %> |
|
7 |
- encoding: utf8 |
|
8 |
- reconnect: true |
|
9 |
- pool: 5 |
|
2 |
+ adapter: <%= ENV['DATABASE_ADAPTER'] || "mysql2" %> |
|
3 |
+ encoding: <%= ENV['DATABASE_ENCODING'] || "utf8" %> |
|
4 |
+ reconnect: <%= ENV['DATABASE_RECONNECT'] || "true" %> |
|
5 |
+ database: <%= ENV['DATABASE_NAME'] || "huginn_development" %> |
|
6 |
+ pool: <%= ENV['DATABASE_POOL'] || "5" %> |
|
7 |
+ username: <%= ENV['DATABASE_USERNAME'] || "root" %> |
|
8 |
+ password: <%= ENV['DATABASE_PASSWORD'] || "" %> |
|
9 |
+ socket: <%= ENV['DATABASE_SOCKET'] || ["/var/run/mysqld/mysqld.sock", "/opt/local/var/run/mysql5/mysqld.sock", "/tmp/mysql.sock"].find{ |path| File.exist? path } %> |
|
10 | 10 |
|
11 | 11 |
# Warning: The database defined as "test" will be erased and |
12 | 12 |
# re-generated from your development database when you run "rake". |
@@ -22,11 +22,11 @@ test: |
||
22 | 22 |
pool: 5 |
23 | 23 |
|
24 | 24 |
production: |
25 |
- adapter: mysql2 |
|
26 |
- encoding: utf8 |
|
27 |
- reconnect: true |
|
28 |
- database: huginn_production |
|
29 |
- pool: 5 |
|
30 |
- username: root |
|
31 |
- password: password |
|
32 |
- socket: /var/run/mysqld/mysqld.sock |
|
25 |
+ adapter: <%= ENV['DATABASE_ADAPTER'] || "mysql2" %> |
|
26 |
+ encoding: <%= ENV['DATABASE_ENCODING'] || "utf8" %> |
|
27 |
+ reconnect: <%= ENV['DATABASE_RECONNECT'] || "true" %> |
|
28 |
+ database: <%= ENV['DATABASE_NAME'] || "huginn_production" %> |
|
29 |
+ pool: <%= ENV['DATABASE_POOL'] || "5" %> |
|
30 |
+ username: <%= ENV['DATABASE_USERNAME'] || "root" %> |
|
31 |
+ password: <%= ENV['DATABASE_PASSWORD'] || "password" %> |
|
32 |
+ socket: <%= ENV['DATABASE_SOCKET'] || ["/var/run/mysqld/mysqld.sock", "/opt/local/var/run/mysql5/mysqld.sock", "/tmp/mysql.sock"].find{ |path| File.exist? path } %> |
@@ -38,12 +38,12 @@ Huginn::Application.configure do |
||
38 | 38 |
config.action_mailer.raise_delivery_errors = true |
39 | 39 |
config.action_mailer.delivery_method = :smtp |
40 | 40 |
config.action_mailer.smtp_settings = { |
41 |
- address: "smtp.gmail.com", |
|
42 |
- port: 587, |
|
43 |
- domain: ENV['GOOGLE_APPS_DOMAIN'], |
|
44 |
- authentication: "plain", |
|
45 |
- enable_starttls_auto: true, |
|
46 |
- user_name: ENV['GMAIL_USERNAME'], |
|
47 |
- password: ENV['GMAIL_PASSWORD'] |
|
41 |
+ address: ENV['SMTP_SERVER'] || 'smtp.gmail.com', |
|
42 |
+ port: ENV['SMTP_PORT'] || 587, |
|
43 |
+ domain: ENV['SMTP_DOMAIN'], |
|
44 |
+ authentication: ENV['SMTP_AUTHENTICATION'] || 'plain', |
|
45 |
+ enable_starttls_auto: ENV['SMTP_ENABLE_STARTTLS_AUTO'] == 'true' ? true : false, |
|
46 |
+ user_name: ENV['SMTP_USER_NAME'], |
|
47 |
+ password: ENV['SMTP_PASSWORD'] |
|
48 | 48 |
} |
49 | 49 |
end |
@@ -68,12 +68,12 @@ Huginn::Application.configure do |
||
68 | 68 |
config.action_mailer.raise_delivery_errors = true |
69 | 69 |
config.action_mailer.delivery_method = :smtp |
70 | 70 |
config.action_mailer.smtp_settings = { |
71 |
- address: "smtp.gmail.com", |
|
72 |
- port: 587, |
|
73 |
- domain: ENV['GOOGLE_APPS_DOMAIN'], |
|
74 |
- authentication: "plain", |
|
75 |
- enable_starttls_auto: true, |
|
76 |
- user_name: ENV['GMAIL_USERNAME'], |
|
77 |
- password: ENV['GMAIL_PASSWORD'] |
|
71 |
+ address: ENV['SMTP_SERVER'] || 'smtp.gmail.com', |
|
72 |
+ port: ENV['SMTP_PORT'] || 587, |
|
73 |
+ domain: ENV['SMTP_DOMAIN'], |
|
74 |
+ authentication: ENV['SMTP_AUTHENTICATION'] || 'plain', |
|
75 |
+ enable_starttls_auto: ENV['SMTP_ENABLE_STARTTLS_AUTO'] == 'true' ? true : false, |
|
76 |
+ user_name: ENV['SMTP_USER_NAME'], |
|
77 |
+ password: ENV['SMTP_PASSWORD'] |
|
78 | 78 |
} |
79 | 79 |
end |
@@ -10,23 +10,17 @@ |
||
10 | 10 |
|
11 | 11 |
# You'll also need to install the backup gem on your server, as well as the net-ssh, excon, net-scp, and fog gems. |
12 | 12 |
|
13 |
-database_yml = '/home/you/app/current/config/database.yml' |
|
14 |
-rails_env = ENV['RAILS_ENV'] || 'production' |
|
15 |
- |
|
16 |
-require 'yaml' |
|
17 |
-config = YAML.load_file(database_yml) |
|
18 |
- |
|
19 | 13 |
Backup::Model.new(:huginn_backup, 'The Huginn backup configuration') do |
20 | 14 |
|
21 | 15 |
split_into_chunks_of 4000 |
22 | 16 |
|
23 | 17 |
database MySQL do |database| |
24 |
- database.name = config[rails_env]["database"] |
|
25 |
- database.username = config[rails_env]["username"] |
|
26 |
- database.password = config[rails_env]["password"] |
|
27 |
- database.host = config[rails_env]["host"] |
|
28 |
- database.port = config[rails_env]["port"] |
|
29 |
- database.socket = config[rails_env]["socket"] |
|
18 |
+ database.name = "your-database-name" |
|
19 |
+ database.username = "your-database-username" |
|
20 |
+ database.password = "your-database-password" |
|
21 |
+ database.host = "your-database-host" |
|
22 |
+ database.port = "your-database-port" |
|
23 |
+ database.socket = "your-database-socket" |
|
30 | 24 |
database.additional_options = ['--single-transaction', '--quick', '--hex-blob', '--add-drop-table'] |
31 | 25 |
end |
32 | 26 |
|
@@ -25,21 +25,31 @@ after 'deploy', 'deploy:cleanup' |
||
25 | 25 |
|
26 | 26 |
set :bundle_without, [:development, :test] |
27 | 27 |
|
28 |
-after "deploy:stop", "delayed_job:stop" |
|
29 |
-after "deploy:start", "delayed_job:start" |
|
30 |
-after "deploy:restart", "delayed_job:restart" |
|
28 |
+after 'deploy:stop', 'delayed_job:stop' |
|
29 |
+after 'deploy:start', 'delayed_job:start' |
|
30 |
+after 'deploy:restart', 'delayed_job:restart' |
|
31 |
+after 'deploy:update_code', 'deploy:symlink_env_config' |
|
32 |
+ |
|
33 |
+namespace :deploy do |
|
34 |
+ desc 'Link the environment file from shared/config/.env into the new deploy directory' |
|
35 |
+ task :symlink_env_config, :roles => :app do |
|
36 |
+ run <<-CMD |
|
37 |
+ cd #{latest_release} && ln -nfs #{shared_path}/config/.env #{latest_release}/.env |
|
38 |
+ CMD |
|
39 |
+ end |
|
40 |
+end |
|
31 | 41 |
|
32 | 42 |
# If you want to use command line options, for example to start multiple workers, |
33 | 43 |
# define a Capistrano variable delayed_job_args: |
34 | 44 |
# |
35 | 45 |
# set :delayed_job_args, "-n 2" |
36 | 46 |
|
37 |
-# If you want to use rvm on the server: |
|
38 |
-# set :rvm_ruby_string, '1.9.3-p286@huginn' |
|
39 |
-# set :rvm_type, :user |
|
40 |
-# before 'deploy', 'rvm:install_rvm' |
|
41 |
-# before 'deploy', 'rvm:install_ruby' |
|
42 |
-# require "rvm/capistrano" |
|
47 |
+# If you want to use rvm on your server and have it maintained by Capistrano, uncomment these lines: |
|
48 |
+# set :rvm_ruby_string, '1.9.3-p286@huginn' |
|
49 |
+# set :rvm_type, :user |
|
50 |
+# before 'deploy', 'rvm:install_rvm' |
|
51 |
+# before 'deploy', 'rvm:install_ruby' |
|
52 |
+# require "rvm/capistrano" |
|
43 | 53 |
|
44 | 54 |
# Load Capistrano additions |
45 | 55 |
Dir[File.expand_path("../../lib/capistrano/*.rb", __FILE__)].each{|f| load f } |