Class: OpalWebpackCompileServer::Exe

Inherits:
Object
  • Object
show all
Defined in:
lib/opal-webpack-loader/compile_server.rb

Class Method Summary collapse

Class Method Details



124
125
126
# File 'lib/opal-webpack-loader/compile_server.rb', line 124

def self.dont_unlink_on_exit
  @unlink = false
end

.run ⇒ Object



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/opal-webpack-loader/compile_server.rb', line 143

def self.run
  if File.exist?(OWCS_SOCKET_PATH) # OWCS already running
    puts 'Another Opal Webpack Compile Server already running, exiting'
    dont_unlink_on_exit
    exit(1)
  else
    unlink_on_exit
    load_paths = OpalWebpackCompileServer::LoadPathManager.get_load_paths
    if load_paths
      Opal.append_paths(*load_paths)
      # Process.daemon(true)
      EventMachine.run do
        EventMachine.start_unix_domain_server(OWCS_SOCKET_PATH, OpalWebpackCompileServer::Compiler)
      end
    end
  end
end

.stop(do_exit = true) ⇒ Object



128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/opal-webpack-loader/compile_server.rb', line 128

def self.stop(do_exit = true)
  if File.exist?(OWCS_SOCKET_PATH)
    dont_unlink_on_exit
    begin
      s = UNIXSocket.new(OWCS_SOCKET_PATH)
      s.send("command:stop\n", 0)
      s.close
    rescue
      # socket cant be reached so owcs is already dead, delete socket
      unlink_on_exit
    end
    exit(0) if do_exit
  end
end


120
121
122
# File 'lib/opal-webpack-loader/compile_server.rb', line 120

def self.unlink_on_exit
  @unlink = true
end

Returns:

  • (Boolean)


116
117
118
# File 'lib/opal-webpack-loader/compile_server.rb', line 116

def self.unlink_socket?
  @unlink
end