redde 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/.gitignore +1 -0
  2. data/README.md +6 -0
  3. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/layouts/page-header.sass +4 -1
  4. data/lib/generators/redde/photo/photo_generator.rb +35 -0
  5. data/lib/generators/redde/photo/templates/controller.rb +30 -0
  6. data/lib/generators/redde/photo/templates/create_photos.rb +13 -0
  7. data/lib/generators/redde/photo/templates/photo.rb +7 -0
  8. data/lib/generators/redde/photo/templates/photos/_photo.haml +5 -0
  9. data/lib/generators/redde/photo/templates/photos/_photos.haml +22 -0
  10. data/lib/generators/redde/photo/templates/photos/create.js.erb +1 -0
  11. data/lib/generators/redde/photo/templates/photos/destroy.js.erb +1 -0
  12. data/lib/generators/redde/photo/templates/uploader.rb +60 -0
  13. data/lib/redde/version.rb +1 -1
  14. data/lib/redde.rb +1 -1
  15. data/spec/generators/photo_generator_spec.rb +33 -0
  16. metadata +15 -35
  17. data/lib/generators/redde/deploy/deploy_generator.rb +0 -34
  18. data/lib/generators/redde/deploy/templates/Capfile +0 -4
  19. data/lib/generators/redde/deploy/templates/deploy.rb +0 -33
  20. data/lib/generators/redde/deploy/templates/recipes/base.rb +0 -16
  21. data/lib/generators/redde/deploy/templates/recipes/check.rb +0 -13
  22. data/lib/generators/redde/deploy/templates/recipes/database.rb +0 -66
  23. data/lib/generators/redde/deploy/templates/recipes/imagemagick.rb +0 -8
  24. data/lib/generators/redde/deploy/templates/recipes/memcached.rb +0 -10
  25. data/lib/generators/redde/deploy/templates/recipes/monit.rb +0 -35
  26. data/lib/generators/redde/deploy/templates/recipes/nginx.rb +0 -26
  27. data/lib/generators/redde/deploy/templates/recipes/nodejs.rb +0 -10
  28. data/lib/generators/redde/deploy/templates/recipes/postfix.rb +0 -37
  29. data/lib/generators/redde/deploy/templates/recipes/rbenv.rb +0 -17
  30. data/lib/generators/redde/deploy/templates/recipes/templates/database.yml.erb +0 -8
  31. data/lib/generators/redde/deploy/templates/recipes/templates/dkim-filter.conf.erb +0 -57
  32. data/lib/generators/redde/deploy/templates/recipes/templates/dkim-filter.defaults.erb +0 -11
  33. data/lib/generators/redde/deploy/templates/recipes/templates/dkim-keys.conf.erb +0 -2
  34. data/lib/generators/redde/deploy/templates/recipes/templates/gemrc.erb +0 -1
  35. data/lib/generators/redde/deploy/templates/recipes/templates/main.cf.erb +0 -43
  36. data/lib/generators/redde/deploy/templates/recipes/templates/memcached.erb +0 -47
  37. data/lib/generators/redde/deploy/templates/recipes/templates/monit_monitrc.erb +0 -21
  38. data/lib/generators/redde/deploy/templates/recipes/templates/monit_nginx.erb +0 -5
  39. data/lib/generators/redde/deploy/templates/recipes/templates/monit_unicorn.erb +0 -14
  40. data/lib/generators/redde/deploy/templates/recipes/templates/nginx_unicorn.erb +0 -28
  41. data/lib/generators/redde/deploy/templates/recipes/templates/unicorn.rb.erb +0 -36
  42. data/lib/generators/redde/deploy/templates/recipes/templates/unicorn_init.erb +0 -84
  43. data/lib/generators/redde/deploy/templates/recipes/unicorn.rb +0 -27
  44. data/spec/dummy/log/test.log +0 -53411
  45. data/spec/generators/deploy_generator_spec.rb +0 -29
@@ -1,37 +0,0 @@
1
- namespace :postfix do
2
- def put_sudo(data, to)
3
- filename = File.basename(to)
4
- to_directory = File.dirname(to)
5
- put data, "/tmp/#{filename}"
6
- run "#{sudo} mv /tmp/#{filename} #{to_directory}"
7
- end
8
-
9
- def template_sudo(from, to)
10
- erb = File.read(File.expand_path("../templates/#{from}", __FILE__))
11
- put_sudo ERB.new(erb).result(binding), to
12
- end
13
-
14
- desc "Install latest stable release of postfix"
15
- task :install, roles: :web do
16
- run "#{sudo} DEBIAN_FRONTEND=noninteractive apt-get -y install postfix"
17
- run "#{sudo} apt-get install -y dkim-filter"
18
- run "#{sudo} mkdir -p /etc/postfix/dkim"
19
- run "#{sudo} dkim-genkey -d #{fqdn} -s mail -r -D /etc/postfix/dkim/"
20
- run "#{sudo} mv /etc/postfix/dkim/mail.private /etc/postfix/dkim/mail"
21
- template_sudo "dkim-keys.conf.erb", "/etc/dkim-keys.conf"
22
- template_sudo "dkim-filter.defaults.erb", "/etc/default/dkim-filter"
23
- run "#{sudo} chgrp postfix /etc/postfix/dkim/"
24
- run "#{sudo} chmod 750 /etc/postfix/dkim/"
25
- template_sudo "main.cf.erb", "/etc/postfix/main.cf"
26
- template_sudo "dkim-filter.conf.erb", "/etc/dkim-filter.conf"
27
- restart
28
- end
29
- after "deploy:install", "postfix:install"
30
-
31
- %w[start stop restart].each do |command|
32
- desc "#{command} postfix"
33
- task command, roles: :web do
34
- run "#{sudo} service postfix #{command} && #{sudo} service dkim-filter #{command}"
35
- end
36
- end
37
- end
@@ -1,17 +0,0 @@
1
- set_default :ruby_version, "1.9.3-p194"
2
-
3
- namespace :rbenv do
4
- desc "Install rbenv, Ruby, and the Bundler gem"
5
- task :install, roles: :app do
6
- run "sudo apt-get -y install curl git-core"
7
- run "curl -L https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash"
8
- run "echo 'export PATH=\"$HOME/.rbenv/bin:$PATH\"' > ~/.bashrc"
9
- run "echo 'eval \"$(rbenv init -)\"' >> ~/.bashrc"
10
- run "rbenv install #{ruby_version}"
11
- run "rbenv global #{ruby_version}"
12
- run "gem install bundler --no-ri --no-rdoc"
13
- run "rbenv rehash"
14
- template "gemrc.erb", "/home/webmaster/.gemrc"
15
- end
16
- after "deploy:install", "rbenv:install"
17
- end
@@ -1,8 +0,0 @@
1
- production:
2
- adapter: mysql2
3
- #encoding: unicode
4
- database: <%= database_database %>
5
- pool: 5
6
- username: <%= database_user %>
7
- password:
8
- host: <%= database_host %>
@@ -1,57 +0,0 @@
1
- # Log to syslog
2
- Syslog yes
3
- # Required to use local socket with MTAs that access the socket as a non-
4
- # privileged user (e.g. Postfix)
5
- UMask 002
6
-
7
- # Sign for example.com with key in /etc/mail/dkim.key using
8
- # selector '2007' (e.g. 2007._domainkey.example.com)
9
- #Domain example.com
10
- #KeyFile /etc/mail/dkim.key
11
- #Selector 2007
12
-
13
- # Common settings. See dkim-filter.conf(5) for more information.
14
- #AutoRestart no
15
- #Background yes
16
- #Canonicalization simple
17
- #DNSTimeout 5
18
- #Mode sv
19
- #SignatureAlgorithm rsa-sha256
20
- #SubDomains no
21
- #ADSPDiscard no
22
- #Version rfc4871
23
- #X-Header no
24
-
25
- ###############################################
26
- # Other (less-standard) configuration options #
27
- ###############################################
28
- #
29
- # If enabled, log verification stats here
30
- #Statistics /var/run/dkim-filter/dkim-stats
31
- #
32
- # KeyList is a file containing tuples of key information. Requires
33
- # KeyFile to be unset. Each line of the file should be of the format:
34
- # sender glob:signing domain:signing key file
35
- # Blank lines and lines beginning with # are ignored. Selector will be
36
- # derived from the key's filename.
37
- #KeyList /etc/dkim-keys.conf
38
- #
39
- # If enabled, will generate verification failure reports for any messages
40
- # that fail signature verification. These will be sent to the r= address
41
- # in the policy record, if any.
42
- #SendReports yes
43
- #
44
- # If enabled, will issue a Sendmail QUARANTINE for any messages that fail
45
- # signature verification, allowing them to be inspected later.
46
- #Quarantine yes
47
- #
48
- # If enabled, will check for required headers when processing messages.
49
- # At a minimum, that means From: and Date: will be required. Messages not
50
- # containing the required headers will not be signed or verified, but will
51
- # be passed through
52
- #RequiredHeaders yes
53
- Canonicalization relaxed/relaxed
54
- KeyList /etc/dkim-keys.conf
55
- Domain *
56
- BodyLengths yes
57
- #On-DNSError accept
@@ -1,11 +0,0 @@
1
- # Command-line options specified here will override the contents of
2
- # /etc/dkim-filter.conf. See dkim-filter(8) for a complete list of options.
3
- #DAEMON_OPTS=""
4
- #
5
- # Uncomment to specify an alternate socket
6
- # Note that setting this will override any Socket value in dkim-filter.conf
7
- #SOCKET="local:/var/run/dkim-filter/dkim-filter.sock" # default
8
- #SOCKET="inet:54321" # listen on all interfaces on port 54321
9
- #SOCKET="inet:12345@localhost" # listen on loopback on port 12345
10
- #SOCKET="inet:12345@192.0.2.1" # listen on 192.0.2.1 on port 12345
11
- SOCKET="inet:8891@localhost"
@@ -1,2 +0,0 @@
1
- *@<%= fqdn %>:<%= fqdn %>:/etc/postfix/dkim/mail
2
- *:<%= fqdn %>:/etc/postfix/dkim/mail
@@ -1 +0,0 @@
1
- gem: --no-ri --no-rdoc
@@ -1,43 +0,0 @@
1
- # See /usr/share/postfix/main.cf.dist for a commented, more complete version
2
-
3
-
4
- # Debian specific: Specifying a file name will cause the first
5
- # line of that file to be used as the name. The Debian default
6
- # is /etc/mailname.
7
- #myorigin = /etc/mailname
8
-
9
- smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
10
- biff = no
11
-
12
- # appending .domain is the MUA's job.
13
- append_dot_mydomain = no
14
-
15
- # Uncomment the next line to generate "delayed mail" warnings
16
- #delay_warning_time = 4h
17
-
18
- readme_directory = no
19
-
20
- # TLS parameters
21
- smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
22
- smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
23
- smtpd_use_tls=yes
24
- smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
25
- smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
26
-
27
- # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
28
- # information on enabling SSL in the smtp client.
29
-
30
- myhostname = <%= fqdn %>
31
- alias_maps = hash:/etc/aliases
32
- alias_database = hash:/etc/aliases
33
- myorigin = /etc/mailname
34
- mydestination = localhost.localdomain, localhost
35
- relayhost =
36
- mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
37
- mailbox_size_limit = 0
38
- recipient_delimiter = +
39
- inet_interfaces = all
40
- milter_default_action = accept
41
- milter_protocol = 2
42
- smtpd_milters = inet:localhost:8891
43
- non_smtpd_milters = inet:localhost:8891
@@ -1,47 +0,0 @@
1
- # memcached default config file
2
- # 2003 - Jay Bonci <jaybonci@debian.org>
3
- # This configuration file is read by the start-memcached script provided as
4
- # part of the Debian GNU/Linux distribution.
5
-
6
- # Run memcached as a daemon. This command is implied, and is not needed for the
7
- # daemon to run. See the README.Debian that comes with this package for more
8
- # information.
9
- -d
10
-
11
- # Log memcached's output to /var/log/memcached
12
- logfile /var/log/memcached.log
13
-
14
- # Be verbose
15
- # -v
16
-
17
- # Be even more verbose (print client commands as well)
18
- # -vv
19
-
20
- # Start with a cap of 64 megs of memory. It's reasonable, and the daemon default
21
- # Note that the daemon will grow to this size, but does not start out holding this much
22
- # memory
23
- -m 64
24
-
25
- # Default connection port is 11211
26
- -p 11211
27
-
28
- # Run the daemon as root. The start-memcached will default to running as root if no
29
- # -u command is present in this config file
30
- -u nobody
31
-
32
- # Specify which IP address to listen on. The default is to listen on all IP addresses
33
- # This parameter is one of the only security measures that memcached has, so make sure
34
- # it's listening on a firewalled interface.
35
- -l 127.0.0.1
36
-
37
- # Limit the number of simultaneous incoming connections. The daemon default is 1024
38
- # -c 1024
39
-
40
- # Lock down all paged memory. Consult with the README and homepage before you do this
41
- # -k
42
-
43
- # Return error when memory is exhausted (rather than removing items)
44
- # -M
45
-
46
- # Maximize core file limit
47
- # -r
@@ -1,21 +0,0 @@
1
- set daemon 30
2
-
3
- set logfile /var/log/monit.log
4
- set idfile /var/lib/monit/id
5
- set statefile /var/lib/monit/state
6
-
7
- set eventqueue
8
- basedir /var/lib/monit/events
9
- slots 100
10
-
11
- # set mailserver smtp.gmail.com port 587
12
- # username "foo@example.com" password "secret"
13
- # using tlsv1
14
- # with timeout 30 seconds
15
-
16
- check system <%= application %>
17
- if loadavg(5min) > 2 for 2 cycles then alert
18
- if memory > 75% for 2 cycles then alert
19
- if cpu(user) > 75% for 2 cycles then alert
20
-
21
- include /etc/monit/conf.d/*
@@ -1,5 +0,0 @@
1
- check process nginx with pidfile /var/run/nginx.pid
2
- start program = "/etc/init.d/nginx start"
3
- stop program = "/etc/init.d/nginx stop"
4
- if children > 250 then restart
5
- if 5 restarts within 5 cycles then timeout
@@ -1,14 +0,0 @@
1
- check process <%= application %>_unicorn with pidfile <%= unicorn_pid %>
2
- start program = "/etc/init.d/<%= application %> start"
3
- stop program = "/etc/init.d/<%= application %> stop"
4
-
5
- <% unicorn_workers.times do |n| %>
6
- <% pid = unicorn_pid.sub(".pid", ".#{n}.pid") %>
7
- check process <%= application %>_unicorn_worker_<%= n %> with pidfile <%= pid %>
8
- start program = "/bin/true"
9
- stop program = "/usr/bin/test -s <%= pid %> && /bin/kill -QUIT `cat <%= pid %>`"
10
- if mem > 200.0 MB for 1 cycles then restart
11
- if cpu > 50% for 3 cycles then restart
12
- if 5 restarts within 5 cycles then timeout
13
- if changed pid 2 times within 60 cycles then alert
14
- <% end %>
@@ -1,28 +0,0 @@
1
- upstream unicorn {
2
- server unix:<%= unicorn_socket %> fail_timeout=0;
3
- }
4
-
5
- server {
6
- listen 80 default deferred;
7
- # server_name example.com;
8
- root <%= current_path %>/public;
9
-
10
- location ^~ /assets/ {
11
- gzip_static on;
12
- expires max;
13
- add_header Cache-Control public;
14
- }
15
-
16
- try_files $uri/index.html $uri @unicorn;
17
- location @unicorn {
18
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
19
- proxy_set_header Host $http_host;
20
- proxy_redirect off;
21
- proxy_pass http://unicorn;
22
- }
23
-
24
- error_page 500 502 503 504 /500.html;
25
- error_page 404 /404.html;
26
- client_max_body_size 4G;
27
- keepalive_timeout 10;
28
- }
@@ -1,36 +0,0 @@
1
- working_directory "<%= current_path %>"
2
- pid "<%= unicorn_pid %>"
3
- stderr_path "<%= unicorn_log %>"
4
- stdout_path "<%= unicorn_log %>"
5
-
6
- listen "<%= unicorn_socket %>"
7
- worker_processes <%= unicorn_workers %>
8
- timeout 120
9
-
10
- preload_app true
11
-
12
- before_fork do |server, worker|
13
- # Disconnect since the database connection will not carry over
14
- if defined? ActiveRecord::Base
15
- ActiveRecord::Base.connection.disconnect!
16
- end
17
-
18
- # Quit the old unicorn process
19
- old_pid = "#{server.config[:pid]}.oldbin"
20
- if File.exists?(old_pid) && server.pid != old_pid
21
- begin
22
- Process.kill("QUIT", File.read(old_pid).to_i)
23
- rescue Errno::ENOENT, Errno::ESRCH
24
- # someone else did our job for us
25
- end
26
- end
27
- end
28
-
29
- after_fork do |server, worker|
30
- # Start up the database connection again in the worker
31
- if defined?(ActiveRecord::Base)
32
- ActiveRecord::Base.establish_connection
33
- end
34
- child_pid = server.config[:pid].sub(".pid", ".#{worker.nr}.pid")
35
- system("echo #{Process.pid} > #{child_pid}")
36
- end
@@ -1,84 +0,0 @@
1
- #!/bin/sh
2
- ### BEGIN INIT INFO
3
- # Provides: unicorn
4
- # Required-Start: $remote_fs $syslog
5
- # Required-Stop: $remote_fs $syslog
6
- # Default-Start: 2 3 4 5
7
- # Default-Stop: 0 1 6
8
- # Short-Description: Manage unicorn server
9
- # Description: Start, stop, restart unicorn server for a specific application.
10
- ### END INIT INFO
11
- set -e
12
-
13
- # Feel free to change any of the following variables for your app:
14
- TIMEOUT=${TIMEOUT-60}
15
- APP_ROOT=<%= current_path %>
16
- PID=<%= unicorn_pid %>
17
- CMD="cd <%= current_path %>; bundle exec unicorn_rails -D -c <%= unicorn_config %> -E production"
18
- AS_USER=<%= unicorn_user %>
19
- set -u
20
-
21
- OLD_PIN="$PID.oldbin"
22
-
23
- sig () {
24
- test -s "$PID" && kill -$1 `cat $PID`
25
- }
26
-
27
- oldsig () {
28
- test -s $OLD_PIN && kill -$1 `cat $OLD_PIN`
29
- }
30
-
31
- run () {
32
- if [ "$(id -un)" = "$AS_USER" ]; then
33
- eval $1
34
- else
35
- su -c "$1" - $AS_USER
36
- fi
37
- }
38
-
39
- case "$1" in
40
- start)
41
- sig 0 && echo >&2 "Already running" && exit 0
42
- run "$CMD"
43
- ;;
44
- stop)
45
- sig QUIT && exit 0
46
- echo >&2 "Not running"
47
- ;;
48
- force-stop)
49
- sig TERM && exit 0
50
- echo >&2 "Not running"
51
- ;;
52
- restart|reload)
53
- sig USR2 && echo reloaded OK && exit 0
54
- echo >&2 "Couldn't reload, starting '$CMD' instead"
55
- run "$CMD"
56
- ;;
57
- upgrade)
58
- if sig USR2 && sleep 2 && sig 0 && oldsig QUIT
59
- then
60
- n=$TIMEOUT
61
- while test -s $OLD_PIN && test $n -ge 0
62
- do
63
- printf '.' && sleep 1 && n=$(( $n - 1 ))
64
- done
65
- echo
66
-
67
- if test $n -lt 0 && test -s $OLD_PIN
68
- then
69
- echo >&2 "$OLD_PIN still exists after $TIMEOUT seconds"
70
- exit 1
71
- fi
72
- exit 0
73
- fi
74
- echo >&2 "Couldn't upgrade, starting '$CMD' instead"
75
- run "$CMD"
76
- ;;
77
- reopen-logs)
78
- sig USR1
79
- ;;
80
- *)
81
- echo >&2 "Usage: $0 <start|stop|restart|upgrade|force-stop|reopen-logs>"
82
- exit 1
83
- ;;
84
- esac
@@ -1,27 +0,0 @@
1
- set_default(:unicorn_user) { user }
2
- set_default(:unicorn_pid) { "#{current_path}/tmp/pids/unicorn.pid" }
3
- set_default(:unicorn_config) { "#{shared_path}/config/unicorn.rb" }
4
- set_default(:unicorn_socket) { "#{current_path}/tmp/unicorn.sock" }
5
- set_default(:unicorn_log) { "#{shared_path}/log/unicorn.log" }
6
- set_default(:unicorn_workers, 2)
7
-
8
- namespace :unicorn do
9
- desc "Setup Unicorn"
10
- task :setup, roles: :app do
11
- run "mkdir -p #{shared_path}/config"
12
- template "unicorn.rb.erb", unicorn_config
13
- template "unicorn_init.erb", "/tmp/unicorn_init"
14
- run "chmod +x /tmp/unicorn_init"
15
- run "sudo mv /tmp/unicorn_init /etc/init.d/#{application}"
16
- run "sudo update-rc.d -f #{application} defaults"
17
- end
18
- after "deploy:setup", "unicorn:setup"
19
-
20
- %w[start stop restart].each do |command|
21
- desc "#{command} unicorn"
22
- task command, roles: :app do
23
- run "sudo service #{application} #{command}"
24
- end
25
- after "deploy:#{command}", "unicorn:#{command}"
26
- end
27
- end