title: Running two web server at the same time in one go programm
body: <p>In a go program, I want to run two web servers at the same time,<br>
  obviously they will be serving on two different ports (and ip addresses if necessary),<br>
  the problem is with the call to <code>http.handle</code>, when I try to register handler for '/' for the second server, it panics and says there is already a handler associated with '/',<br>
  I guess I need to create a mux in addition to the <code>DefaultServeMux</code> and I tried to do it using the <code>gorillaMux</code> but couldn't figure it out,  </p>
  
  <p>Is there something fundamentally wrong with running two web servers in the same program/process.  </p>
  
  <p>To make it more clear, one of the two web servers is a being used as a regular web server, I need the second one to act as an RPC server to communicate stuff between instances of the program running on different nodes of a cluster,  </p>
  
  <p>EDIT: to make it a bit more clear, this is not the actual code but it is the gist    </p>
  
  <pre><code>myMux := http.NewServeMux()
  myMux.HandleFunc("/heartbeat", heartBeatHandler)
  
  http.Handle("/", myMux)
  
  server := &amp;http.Server{
      Addr:    ":3400",
      Handler: myMux,
  }
  go server.ListenAndServe()
  
  gorillaMux := mux.NewRouter()
  gorillaMux.HandleFunc("/", indexHandler)
  gorillaMux.HandleFunc("/book", bookHandler)
  
  http.Handle("/", gorillaMux)
  
  server := &amp;http.Server{
      Addr:    ":1234",
      Handler: gorillaMux,
  }
  
  log.Fatal(server.ListenAndServe())
  </code></pre>