Sha256: 9d31f778fd1c46bd9cef96818871ff99645ccea8e4d62bcf76ee8775e07e99fe

Contents?: true

Size: 694 Bytes

Versions: 3

Compression:

Stored size: 694 Bytes

Contents

require 'sys/proctable'

module Neutron

  class App

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

    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

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
neutron-ruby-electron-0.1.2 lib/neutron/app.rb
neutron-ruby-electron-0.1.1 lib/neutron/app.rb
neutron-ruby-electron-0.1.0 lib/neutron/app.rb