Sha256: a1bae6c9dcc71733ed3922a03fbbb8946dee8416a22058affa732f5bce0c15fb
Contents?: true
Size: 1.41 KB
Versions: 2
Compression:
Stored size: 1.41 KB
Contents
module Rhoconnect class Node class << self attr_accessor :started,:pipe end @started = false @pipe = nil def self.shell_node package_file = File.join(Dir.pwd,'package.json') if not File.exists?(package_file) Rhoconnect.use_node = false log "No `package.json` detected, disabling JavaScript support." return end if which("node") begin if @started kill_process end @started = true dir = File.expand_path(File.dirname(__FILE__)) pwd = Dir.pwd node_modules = File.join(pwd,'node_modules') sub_env = { "NODE_PATH" => "#{node_modules}#{File::PATH_SEPARATOR}#{pwd}#{File::PATH_SEPARATOR}#{dir}" } file = File.join(dir,"server.js") args = [sub_env, "node", file, "#{$$}", Rhoconnect.environment.to_s] @pipe = IO.popen(args) log "Started Node.js process: #{@pipe.pid}" @pipe rescue Exception=>e puts "Node.js startup error: #{e.message}\n" puts e.backtrace.join("\n") raise e end else Rhoconnect.use_node = false log "Node.js not detected, disabling JavaScript support." end end def self.kill_process log "Stopping Node.js process: #{@pipe.pid}" if @pipe NodeChannel.exit_node @started = false @pipe = nil end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rhoconnect-4.0.0.beta.10 | js-adapters/node.rb |
rhoconnect-4.0.0.beta.12 | js-adapters/node.rb |