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 +4 -4
- data/README.md +46 -0
- data/lib/daemonize_rails.rb +7 -1
- data/lib/daemonize_rails/version.rb +1 -1
- data/lib/generators/daemonize_rails/install_generator.rb +13 -5
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1ee38a7b977341ae66f9eb399335b1cb1feabd0c
|
|
4
|
+
data.tar.gz: a32c8691895b352b1a9b21cc080ff13579902319
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 16ed86a8d0f2193235be6f7b04726127dfb59e9df2968171c46de2fc51c009e38a9889a6e4514e358da573f0d50052c978cd5ca540ef571ff3972e387ef32fdb
|
|
7
|
+
data.tar.gz: 7a930f2a654db8c4d9e35db89daadbf2fe8dfd345f8f04ff72bba2cedaed95c262fd2a7897a4778d3643eebc0043220324d7ab5ae3adbb716a1fbe0d4843d1fe
|
data/README.md
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
[](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
|
data/lib/daemonize_rails.rb
CHANGED
|
@@ -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
|
-
|
|
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,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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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.
|
|
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-
|
|
11
|
+
date: 2014-10-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|