Class: Neutron::App

Inherits:
Object
  • Object
show all
Defined in:
lib/neutron/app.rb

Instance Method Summary collapse

Constructor Details

#initialize(controller:) ⇒ App

Returns a new instance of App.



7
8
9
10
# File 'lib/neutron/app.rb', line 7

def initialize(controller:)
  raise 'Controller must be inherit from Neutron::Controller' unless controller.is_a?(::Neutron::Controller)
  @controller = controller
end

Instance Method Details

#runObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/neutron/app.rb', line 12

def run
  path = File.expand_path('..', caller[0].split(':').first)
  begin
    Thread.new { @controller.run }
    `cd '#{path}' && npm run boot`
  ensure
    process_path = File.join(path, 'node_modules/electron-prebuilt-compile/lib/es6-init.js')
    p = Sys::ProcTable.ps.select { |p| p.cmdline.include?(process_path) }.first
    Process.kill('HUP', p.pid) if p
    @controller.stop
  end
end