Quintus/cinch-plugins

http_server initializes twice

stowns opened this issue · 2 comments

I'm writing a plugin that implements http_server and noticed that the server attempts to initialize twice. Can anyone see anything wrong w/ the following? It outputs "II Starting HTTP server" twice which results in 'eventmachine.rb:526:in `start_tcp_server': no acceptor (port is in use or requires root privileges) (RuntimeError)'

class Cinch::Parallel
  include Cinch::Plugin
  extend Cinch::HttpServer::Verbs

  match /echo (.*)/

  get "/greet" do
      # Print a message into all joined IRC channels
    bot.channels.each{|channel| channel.send("Hi to everyone!")}

      # HTTP statuscode
    204 # No Content
  end
end

and my bot file

require 'cinch'
require_relative "plugins/http_server"
require_relative "plugins/parallel/parallel"

bot = Cinch::Bot.new do
  configure do |c|
    c.server = "0.0.0.0"
    c.nick = "nick"
    c.channels = ["#test"]

    ################
    # => plugin opts
    ################
    c.plugins.options[Cinch::HttpServer] = {
      :host => "0.0.0.0",
      :port => 8080,
      :logfile => "/var/log/cinch-http-server.log" # OPTIONAL
    }

    ###############
    # load plugins
    ###############
    c.plugins.plugins = [Cinch::HttpServer, Cinch::Parallel]

  end
end

bot.start

@stowns, I’m unable to reproduce that. I copied your examples and adjusted the server and logfile settings so it worked for me, but the HTTP server is starting just once and works as expected.

Are you sure you aren’t accidentally starting two bots or so? And you are not including the HTTP server plugin twice?

I apologize for the late reply, but GitHub doesn’t send me emails on new issues for unknown reasons. I don’t actively monitor this repository, thus I failed to see your ticket.

Vale,
Quintus

No reply from OP, so closing this.

Vale,
Quintus