daemonize_rails 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f10cbd026aa8a5e990c19f720ec2f02964ac7699
4
- data.tar.gz: 83f95cebc8ba70e37b6e34b902a0c043cccf046e
3
+ metadata.gz: 1ee38a7b977341ae66f9eb399335b1cb1feabd0c
4
+ data.tar.gz: a32c8691895b352b1a9b21cc080ff13579902319
5
5
  SHA512:
6
- metadata.gz: d257eb21d91b007fb836ccc702ccd1c0c507c60dfafcece7110035e0a6dcfd7494f1092d1c24e6b851e07c1aa146485cfa6b26a9582497cf514eaf8af5a6b92a
7
- data.tar.gz: 3e53e9b909fedb803f8816428341e129d797ec120ed7b89cd06db6a9b8a178fe3405a9279ba15367392b9c0f17d8fd4f12d09cfd7da387517d0c8795d32e44e2
6
+ metadata.gz: 16ed86a8d0f2193235be6f7b04726127dfb59e9df2968171c46de2fc51c009e38a9889a6e4514e358da573f0d50052c978cd5ca540ef571ff3972e387ef32fdb
7
+ data.tar.gz: 7a930f2a654db8c4d9e35db89daadbf2fe8dfd345f8f04ff72bba2cedaed95c262fd2a7897a4778d3643eebc0043220324d7ab5ae3adbb716a1fbe0d4843d1fe
data/README.md CHANGED
@@ -1,3 +1,4 @@
1
+ [![Gem Version](https://badge.fury.io/rb/daemonize_rails.svg)](http://badge.fury.io/rb/daemonize_rails)
1
2
  # Daemonize Rails
2
3
 
3
4
  Daemonize Rails will configure your server to add a new daemon process for your rails app in production.
@@ -14,6 +15,10 @@ Add Daemonize Rails and Unicorn to your Rails app's Gemfile:
14
15
  Then run bundle:
15
16
 
16
17
  $ bundle
18
+
19
+ Install Nginx
20
+
21
+ $ sudo apt-get install nginx
17
22
 
18
23
  ## Usage
19
24
 
@@ -36,6 +41,47 @@ You can also
36
41
  $ /etc/init.d/myapp stop
37
42
  $ /etc/init.d/myapp restart
38
43
 
44
+ ###Configure Nginx
45
+
46
+ Add the following to /etc/nginx/sites-enabled/nginx.conf
47
+
48
+
49
+ ```
50
+ upstream <myapp> {
51
+ server unix:/tmp/unicorn.<myapp>.sock fail_timeout=0;
52
+ }
53
+
54
+ server {
55
+ server_name <mydomain>.com;
56
+ rewrite ^(.*) http://www.<mydomain>.com$1 permanent;
57
+ }
58
+
59
+ server {
60
+ listen 80;
61
+ server_name www.<mydomain>.com;
62
+ root /var/www/<myapp>/public;
63
+
64
+ location ^~ /assets/ {
65
+ gzip_static on;
66
+ expires max;
67
+ add_header Cache-Control public;
68
+ }
69
+
70
+ try_files $uri/index.html $uri @<myapp>;
71
+ location @<myapp> {
72
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
73
+ proxy_set_header Host $http_host;
74
+ proxy_redirect off;
75
+ proxy_pass http://<myapp>;
76
+ }
77
+
78
+ error_page 500 502 503 504 /500.html;
79
+ client_max_body_size 20M;
80
+ keepalive_timeout 10;
81
+ }
82
+
83
+ ```
84
+
39
85
  Enjoy!
40
86
 
41
87
  ## Contributing
@@ -33,7 +33,13 @@ module DaemonizeRails
33
33
  def make_config_file
34
34
  init_file = ERB.new File.new(File.dirname(__FILE__) + "/init_template.erb").read, nil, "%"
35
35
  init_path = "/etc/init.d/#{@app_name}"
36
- init_output = File.open(init_path, 'w') { |f| f.puts init_file.result(@bindings) }
36
+ if ENV["USER"] != "root"
37
+ File.open("./tempfile", 'w') { |f| f.puts init_file.result(@bindings) }
38
+ command = "sh -c 'cat ./tempfile > #{init_path}'"
39
+ system "sudo -p 'You don't have permissions to update init! Enter sudo password: ' #{command}"
40
+ else
41
+ init_output = File.open(init_path, 'w') { |f| f.puts init_file.result(@bindings) }
42
+ end
37
43
  end
38
44
  end
39
45
 
@@ -1,3 +1,3 @@
1
1
  module DaemonizeRails
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,5 +1,6 @@
1
1
  require 'rails/generators'
2
2
  require 'rails/generators/base'
3
+ require 'daemonize_rails'
3
4
 
4
5
  module DaemonizeRails
5
6
  class Generators
@@ -26,11 +27,18 @@ module DaemonizeRails
26
27
  print app_name
27
28
  print "\n"
28
29
 
29
- `chmod 755 ./config/unicorn.rb`
30
- init_path = "/etc/init.d/#{@app_name}"
31
- `chmod 755 /etc/init.d/#{app_name}`
32
- `chmod +x /etc/init.d/#{app_name}`
33
- `update-rc.d #{app_name} defaults`
30
+ if ENV["USER"] != "root"
31
+ command_pre = "sudo -p 'You don't have permissions to update init! Enter sudo password: ' "
32
+ else
33
+ command_pre = ""
34
+ end
35
+ commands = ["chmod 755 ./config/unicorn.rb",
36
+ "chmod 755 /etc/init.d/#{app_name}",
37
+ "chmod +x /etc/init.d/#{app_name}",
38
+ "update-rc.d #{app_name} defaults"]
39
+ commands.each do |command|
40
+ system command_pre + command
41
+ end
34
42
  end
35
43
  end
36
44
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daemonize_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-23 00:00:00.000000000 Z
11
+ date: 2014-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler