class DaemonizeRails::Init
Public Class Methods
new(bindings, app_name)
click to toggle source
# File lib/daemonize_rails.rb, line 28 def initialize(bindings, app_name) @bindings = bindings @app_name = app_name end
Public Instance Methods
make_config_file()
click to toggle source
# File lib/daemonize_rails.rb, line 33 def make_config_file init_file = ERB.new File.new(File.dirname(__FILE__) + "/init_template.erb").read, nil, "%" init_path = "/etc/init.d/#{@app_name}" if ENV["USER"] != "root" File.open("./tempfile", 'w') { |f| f.puts init_file.result(@bindings) } command = "sh -c 'cat ./tempfile > #{init_path}'" system "sudo -p 'You don't have permissions to update init! Enter sudo password: ' #{command}" else init_output = File.open(init_path, 'w') { |f| f.puts init_file.result(@bindings) } end end