Sha256: 7ae6731be8ef46e86822d609baa8d833644ca7c32cd69bd79ee04a8c60e49cd7

Contents?: true

Size: 1.77 KB

Versions: 2

Compression:

Stored size: 1.77 KB

Contents

#!/usr/bin/env ruby -wKU

require "logger"

module Scout
  class Command
    class Stream < Command
      PID_FILENAME="streamer.pid"

      def run
        @key = @args[0]
        daemon_command = @args[1]
        @plugin_ids = @options[:plugin_ids]

        if !@key
          puts "usage: scout stream [your_scout_key] [start|stop]"
          exit(1)
        end

        # server and history methods are inherited from Scout::Command base class
        streamer_log_file=File.join(File.dirname(history),"scout_streamer.log")
        streamer_pid_file=File.join(File.dirname(history),"scout_streamer.pid")

        streamer_control_options = {:log_file => streamer_log_file,
                                    :pid_file => streamer_pid_file,
                                    :sync_log => true,
                                    :working_dir => File.dirname(history)}

        # we use STDOUT for the logger because daemon_spawn directs STDOUT to a log file
        streamer_control_args = [server, @key, history, @plugin_ids, @options[:streaming_key],Logger.new(STDOUT)]

        if daemon_command.include? "start" # can be 'start' or 'restart'
          if File.exists?(streamer_pid_file)
            puts("PID file existed. Restarting ...") if $stdin.tty?
            Scout::StreamerControl.restart(streamer_control_options,streamer_control_args)
          else
            puts("Starting ... ") if $stdin.tty?
            Scout::StreamerControl.start(streamer_control_options,streamer_control_args)
          end
        elsif daemon_command == "stop"
          puts("Stopping ...") if $stdin.tty?
          Scout::StreamerControl.stop(streamer_control_options,[])
        else
          puts "usage: scout stream [your_scout_key] [start|stop]"
          exit(1)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
scout-5.4.6.alpha lib/scout/command/stream.rb
scout-5.4.5.1.alpha lib/scout/command/stream.rb