Sha256: 274637e762aaed593dda4bad6e4cf66c5e638a29b2c085bcbc526732b96368d6

Contents?: true

Size: 891 Bytes

Versions: 3

Compression:

Stored size: 891 Bytes

Contents

namespace :websocket_rails do
  desc 'Test rails task'
  task :start_server do
    require "thin"
    load "#{Rails.root}/config/initializers/events.rb"

    options = WebsocketRails.thin_options

    unless WebsocketRails.standalone?
      warn_standalone_not_enabled!
    end

    fork do
      Thin::Controllers::Controller.new(options).start
    end

    puts "Websocket Rails Standalone Server listening on port #{options[:port]}"
  end

  task :stop_server do
    require "thin"
    load "#{Rails.root}/config/initializers/events.rb"

    options = WebsocketRails.thin_options

    unless WebsocketRails.standalone?
      warn_standalone_not_enabled!
    end

    Thin::Controllers::Controller.new(options).stop
  end
end

def warn_standalone_not_enabled!
  puts "Fail!"
  puts "You must enable standalone mode in your events.rb initializer to use the standalone server."
  exit 1
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
websocket-rails-0.3.0 lib/rails/tasks/websocket_rails.tasks
websocket-rails-0.2.1 lib/rails/tasks/websocket_rails.tasks
websocket-rails-0.2.0 lib/rails/tasks/websocket_rails.tasks