nlp/nlp_route/lib/nlp_route/nlp_launcher.rb
# get all package from webapp in json format and store in /nlp/import/ then start nlp
get all package from webapp in json format and store in /nlp/import/ then start nlp
get all package from webapp in json format and store in / nlp / import / then start nlp
def start(start_nlp = true)
      $stdout.sync = true
      if start_nlp
        FileUtils.rm(pidfile, force: true)
        starting = true
        command = './ogm_nls'
        if MASSIF
          commands = []
          commands << 'G_DEBUG=resident-modules'
          commands << 'G_SLICE=always-malloc'
          commands << 'NLP_JS_DUK_GC_PERIOD=1'
          commands << 'valgrind --tool=massif'
          commands << '--time-unit=ms'
          commands << '--threshold=0.1'
          commands << '--max-snapshots=500'
          commands << '--detailed-freq=1'
          commands << '--massif-out-file=massif-output.txt'
          commands << command
          command = commands.join(' ')
        end
        @@nls_background = Thread.new do
          Thread.current.name = "Nls launcher"
          begin
            NlpLauncher.exec(command)
          rescue StandardError => e
            puts "Nls crashed : #{e.inspect}"
            starting = false
          end
        end
        sleep(0.05) while starting && !File.exist?(pidfile)
        raise 'Stopping' unless File.exist?(pidfile)
      end
      init
      begin
        tries ||= 10
        subscribe
      rescue StandardError => e
        if @subcribe_was_success
          puts "Subscribe ends : #{e.inspect}"
          sleep 3
          retry unless (tries -= 1).zero?
          raise 'Subscribe failed'
        else
          puts "Subscribe failed : #{e.inspect}"
          raise 'Subscribe failed'
        end
      end
    end
def start ( start_nlp = true ) $stdout . sync = true if start_nlp FileUtils . rm ( pidfile , force : true ) starting = true command = './ogm_nls' if MASSIF commands = [ ] commands << 'G_DEBUG=resident-modules' commands << 'G_SLICE=always-malloc' commands << 'NLP_JS_DUK_GC_PERIOD=1' commands << 'valgrind --tool=massif' commands << '--time-unit=ms' commands << '--threshold=0.1' commands << '--max-snapshots=500' commands << '--detailed-freq=1' commands << '--massif-out-file=massif-output.txt' commands << command command = commands . join ( ' ' ) end @@nls_background = Thread . new do Thread . current . name = "Nls launcher" begin NlpLauncher . exec ( command ) rescue StandardError => e puts "Nls crashed : #{e.inspect}" starting = false end end sleep ( 0.05 ) while starting && ! File . exist? ( pidfile ) raise 'Stopping' unless File . exist? ( pidfile ) end init begin tries ||= 10 subscribe rescue StandardError => e if @subcribe_was_success puts "Subscribe ends : #{e.inspect}" sleep 3 retry unless ( tries -= 1 ) . zero? raise 'Subscribe failed' else puts "Subscribe failed : #{e.inspect}" raise 'Subscribe failed' end end end
get all package from webapp in json format and store in /nlp/import/ then start nlp
get all package from webapp in json format and store in / nlp / import / then start nlp
# all immediate stdout # wait for starting # Send all package to NLP # subscribe
start_nlp
<not_specific>