Class: Asmodai::CLI
- Inherits:
-
Thor
- Object
- Thor
- Asmodai::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/asmodai/cli.rb
Instance Attribute Summary collapse
-
#app_name ⇒ Object
Returns the value of attribute app_name.
Class Method Summary collapse
Instance Method Summary collapse
- #console ⇒ Object
- #foreground ⇒ Object
- #install ⇒ Object
- #new(name) ⇒ Object
- #start ⇒ Object
- #status ⇒ Object
- #stop ⇒ Object
- #version ⇒ Object
Instance Attribute Details
#app_name ⇒ Object
Returns the value of attribute app_name.
5 6 7 |
# File 'lib/asmodai/cli.rb', line 5 def app_name @app_name end |
Class Method Details
.source_root ⇒ Object
7 8 9 |
# File 'lib/asmodai/cli.rb', line 7 def self.source_root File.join(File.dirname(__FILE__), "generator") end |
Instance Method Details
#console ⇒ Object
90 91 92 93 |
# File 'lib/asmodai/cli.rb', line 90 def console klass = Asmodai::Info.current.daemon_class exec "irb -Ilib -r rubygems -r asmodai -r ./#{klass.daemon_name}" end |
#foreground ⇒ Object
51 52 53 54 |
# File 'lib/asmodai/cli.rb', line 51 def foreground instance=Asmodai::Info.current.daemon_class.new instance.foreground end |
#install ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/asmodai/cli.rb', line 29 def install @info = Asmodai::Info.current @asmodai = "asmodai" path = "/etc/init.d/#{@info.daemon_name}" IO.popen "sudo bash -c \"cat > #{path}; chmod a+x #{path}\"", "r+" do |io| template_path = File.join( File.dirname(__FILE__), "generator/templates/init_d.erb") io.puts ERB.new(File.read(template_path)).result(binding) io.close end if [:autostart] if (update_bin=`which update-rc.d`.strip).blank? warn "update-rc.d was not found. Omitting autostart installation." else `#{update_bin} #{@info.daemon_name} defaults` end end end |
#new(name) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/asmodai/cli.rb', line 12 def new(name) @app_name=name empty_directory "#{name}/log" empty_directory "#{name}/lib" empty_directory "#{name}/script" template 'templates/daemon.rb.erb', "#{name}/#{name}.rb" copy_file 'templates/Gemfile', "#{name}/Gemfile" template 'templates/asmodai.erb', "#{name}/script/asmodai" FileUtils.chmod 0755, "#{name}/script/asmodai" end |
#start ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/asmodai/cli.rb', line 57 def start klass = Asmodai::Info.current.daemon_class puts "Starting #{klass.daemon_name}" if klass.start puts "Ok." else puts "#{klass.daemon_name} seems to be already running" end end |
#status ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'lib/asmodai/cli.rb', line 80 def status klass = Asmodai::Info.current.daemon_class if !klass.is_running? puts "#{klass.daemon_name} doesn't seem to be running" else puts "#{klass.daemon_name} runs with pid #{klass.pid}" end end |