daemonize_rails 0.0.1 → 0.0.2

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: 4469f0167727400cd7a191b35875b1b6471d7b13
4
- data.tar.gz: fe8c9f443c25648a551a25a0e6f7dd1766814e9d
3
+ metadata.gz: f10cbd026aa8a5e990c19f720ec2f02964ac7699
4
+ data.tar.gz: 83f95cebc8ba70e37b6e34b902a0c043cccf046e
5
5
  SHA512:
6
- metadata.gz: 6e90c0fbc51ed336bbfcacebfc846072649b186412bf5476078e321c0afe8466bf5edd5923c7556aaab363b4c26c9ca18e89576fdec381d16fd86422e59a44ff
7
- data.tar.gz: 9893e589bf08f333fd4296a69ea18a1dd244f25bb38f47f196d1e807b144e4ef03e2b3fe7b23e1ae164bdc8df4bad1c59ca65602ef57e14501d2c0676f80e28a
6
+ metadata.gz: d257eb21d91b007fb836ccc702ccd1c0c507c60dfafcece7110035e0a6dcfd7494f1092d1c24e6b851e07c1aa146485cfa6b26a9582497cf514eaf8af5a6b92a
7
+ data.tar.gz: 3e53e9b909fedb803f8816428341e129d797ec120ed7b89cd06db6a9b8a178fe3405a9279ba15367392b9c0f17d8fd4f12d09cfd7da387517d0c8795d32e44e2
Binary file
data/README.md CHANGED
@@ -1,26 +1,42 @@
1
1
  # Daemonize Rails
2
2
 
3
- **Intended for use with Debian/Ubuntu, Unicorn and Nginx**
4
-
5
- Daemonize Rails will configure your server to add a new process for your rails app in production.
3
+ Daemonize Rails will configure your server to add a new daemon process for your rails app in production.
6
4
 
7
5
  ## Installation
8
6
 
9
- Add this line to your application's Gemfile:
7
+ **Intended for use with Debian/Ubuntu, Unicorn and Nginx**
8
+
9
+ Add Daemonize Rails and Unicorn to your Rails app's Gemfile:
10
10
 
11
11
  gem 'daemonize_rails'
12
+ gem 'unicorn'
12
13
 
13
- And then execute:
14
+ Then run bundle:
14
15
 
15
16
  $ bundle
16
17
 
17
- Or install it yourself as:
18
+ ## Usage
18
19
 
19
- $ gem install daemonize_rails
20
+ Place your Rails project in "/var/www/projectname"
20
21
 
21
- ## Usage
22
+ Run the generator:
23
+
24
+ rails generate daemonize_rails:install
25
+
26
+ This will create your unicorn.rb and init.d file
27
+
28
+ Finally, start your app
29
+
30
+ $ /etc/init.d/myapp start
31
+ [myapp][22645]: Trying to start server...
32
+ [myapp][22668]: server started
33
+
34
+ You can also
22
35
 
23
- TODO: Write usage instructions here
36
+ $ /etc/init.d/myapp stop
37
+ $ /etc/init.d/myapp restart
38
+
39
+ Enjoy!
24
40
 
25
41
  ## Contributing
26
42
 
Binary file
@@ -6,15 +6,14 @@ module DaemonizeRails
6
6
  def initialize(bindings, app_name)
7
7
  @bindings = bindings
8
8
  @app_name = app_name
9
- @app_path = "/var/www/#{app_name}"
9
+ @app_path = Dir.pwd
10
10
  end
11
11
 
12
- def create_file
13
- #check_and_create_folder(@app_path + "/tmp")
14
- #check_and_create_folder(@app_path + "/tmp/pids")
15
- unicorn_file = ERB.new File.new("unicorn_template.erb").read, nil, "%"
16
- create_file "config/unicorn.rb", unicorn_file.result(@bindings)
17
- puts `chmod 755 ./config/unicorn.rb`
12
+ def make_config_file
13
+ check_and_create_folder(@app_path + "/tmp")
14
+ check_and_create_folder(@app_path + "/tmp/pids")
15
+ unicorn_file = ERB.new File.new(File.dirname(__FILE__) + "/unicorn_template.erb").read, nil, "%"
16
+ unicorn_file.result(@bindings)
18
17
  end
19
18
 
20
19
  def check_and_create_folder(path)
@@ -31,13 +30,10 @@ module DaemonizeRails
31
30
  @app_name = app_name
32
31
  end
33
32
 
34
- def create_file
35
- init_file = ERB.new File.new("init_template.erb").read, nil, "%"
36
- init_output = open("/etc/init.d/#{@app_name}", 'w') { |f| f.puts init_file.result(@bindings) }
37
- init_output.close
38
- puts `chmod 755 /etc/init.d/#{app_name}`
39
- puts `chmod +x /etc/init.d/#{app_name}`
40
- puts `update-rc.d #{app_name} defaults`
33
+ def make_config_file
34
+ init_file = ERB.new File.new(File.dirname(__FILE__) + "/init_template.erb").read, nil, "%"
35
+ init_path = "/etc/init.d/#{@app_name}"
36
+ init_output = File.open(init_path, 'w') { |f| f.puts init_file.result(@bindings) }
41
37
  end
42
38
  end
43
39
 
@@ -1,3 +1,3 @@
1
1
  module DaemonizeRails
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
Binary file
@@ -0,0 +1,37 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/base'
3
+
4
+ module DaemonizeRails
5
+ class Generators
6
+ class InstallGenerator < Rails::Generators::Base
7
+ def install
8
+ app_path = Dir.pwd
9
+ # if app_path[/^\/var\/www\/[a-zA-Z0-9\-_.]+/] != app_path
10
+ # raise "Folder check invalid. Please put you Rails project in \"/var/www\""
11
+ # end
12
+ app_name = Dir.pwd[/[A-Za-z0-9_.-]*?(\/|)$/].gsub("/","")
13
+
14
+ unicorn_binding = DaemonizeRails::UnicornConfig.new(app_name, 4).get_binding
15
+ init_binding = DaemonizeRails::InitConfig.new(app_name, `echo $PATH`.chomp).get_binding
16
+
17
+ unicorn = DaemonizeRails::Unicorn.new(unicorn_binding, app_name)
18
+ init = DaemonizeRails::Init.new(init_binding, app_name)
19
+
20
+ create_file "config/unicorn.rb" do
21
+ "#{unicorn.make_config_file}"
22
+ end
23
+
24
+ init.make_config_file
25
+ print "\e[1;32m create\e[0m /etc/init.d/"
26
+ print app_name
27
+ print "\n"
28
+
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`
34
+ end
35
+ end
36
+ end
37
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daemonize_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Smith
@@ -42,20 +42,23 @@ description: Daemonize Rails will configure your server to add a new process for
42
42
  rails app in production.
43
43
  email:
44
44
  - joel@trosic.com
45
- executables:
46
- - daemonize_rails
45
+ executables: []
47
46
  extensions: []
48
47
  extra_rdoc_files: []
49
48
  files:
49
+ - ".DS_Store"
50
50
  - ".gitignore"
51
51
  - Gemfile
52
52
  - LICENSE
53
53
  - README.md
54
54
  - Rakefile
55
- - bin/daemonize_rails
56
55
  - daemonize_rails.gemspec
56
+ - lib/.DS_Store
57
57
  - lib/daemonize_rails.rb
58
58
  - lib/daemonize_rails/version.rb
59
+ - lib/generators/.DS_Store
60
+ - lib/generators/daemonize_rails/.DS_Store
61
+ - lib/generators/daemonize_rails/install_generator.rb
59
62
  - lib/init_template.erb
60
63
  - lib/unicorn_template.erb
61
64
  homepage: http://www.github.com/jbsmith86/daemonize_rails
@@ -1,18 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'daemonize_rails'
4
-
5
- app_path = Dir.pwd
6
-
7
- if app_path[/^\/var\/www\/[a-zA-Z0-9\-_.]+/] != app_path
8
- raise "Folder check invalid. Please put you Rails project in \"/var/www\""
9
- end
10
-
11
- unicorn_binding = DaemonizeRails::UnicornConfig.new(app_name, workers).get_binding
12
- init_binding = DaemonizeRails::InitConfig.new(app_name, `echo $PATH`.chomp).get_binding
13
-
14
- unicorn = DaemonizeRails::Unicorn.new(unicorn_binding, app_name)
15
- init = DaemonizeRails::Init.new(unicorn_binding, app_name)
16
-
17
- unicorn.create_file
18
- init.create_file