1. Guest, as per the stickied thread, this forum has not been in use since 2014. All bugs and feature requests should be posted to JIRA.

Solved Duplicate server instances

Discussion in 'Bugs & Feature Requests' started by ItsHarry, Jun 22, 2013.

  1. For some reason I'm able to start up my server two times, while the port is already in use.

    I did this accidentally and it caused some issues.

    Not sure if this is Bukkit or Spigot. Not really a major bug, but I think it's safer to have this
     
  2. What OS are you running? Can you post the server.log of both starting instances (if it didn't mess up the logs)?

    Having had a similar issue before, the second instance just errored on start and couldn't bind to it's port. I don't think it caused any major issues - just that instance was not usable. This sounds different to what happened for you?
     
  3. joehot200

    Supporter

    This command can kill all processes using a certain port:

    netstat -ntlp | awk '$4~/:*25565$/{gsub(/\/.*/,"",$NF);cmd="kill -9 "$NF;system(cmd)}'
     
  4. I'm running CentOS 6.2

    The second server was usable, but nobody connected to it. The problem is that the second instance locked the save file so the first instance couldn't save it.

    I don't have the server logs anymore, it's exactly the same as every other startup.
     
  5. joehot200

    Supporter

    @ItsHarry, Its because 2 servers are trying to access the same file.

    md_5, confirming bug because this happens to me too (Though i dont make this mistake any more).

    ItsHarry, just as a thought why not run that command line i gave you at the top of the script? This would mean that when the server is starting up it will automatically kill any server that is also on the same port (Change the 25565 to the port you want).
     
  6. Meh, I'd rather just have this bug fixed, it's for safety anyway.
    and I think force killing processes is bad
     
  7. md_5

    Administrator Developer

    Technically its not a bug, Spigot now has the ability to start listening on multiple ports / IP addresses, and we don't kill the server if we cannot listen to one. I can print a stack trace, but do we really want to kill the server if it can't bind to any?
     
  8. If you don't kill the server, you lock the save file causing rollbacks if not noticed in time which is way worse (in my opinion).
    A little config option in bungee.yml maybe? (Your choice, obviously)
     
    • Agree Agree x 1
  9. joehot200

    Supporter

    @md_5, You have a point, But it would of c.ourse clear the way for the new server process to take up the port, which in some cases could be useful @ItsHarry was gonna suggest that too, but edited it out of the message :D
     
  10. md_5

    Administrator Developer

    The save file already locks itself.
     
    • Informative Informative x 1
  11. Yeah, I can start two servers, end the newest one and look back at the old one, errors occur.
     
    • Agree Agree x 1
  12. Not for me. When I start the server two times, the second server locks the save file and the first server (which has players playing on it) can't use it anymore, causing rollbacks.
     
  13. joehot200

    Supporter

    @ItsHarry, you can of course do save-all every 5 minutes which will stop the rollbacks.
     
  14. Did you even read what I wrote? The second server locks the save-file of the first server, save-all doesn't do anything.. -_-
     
  15. md_5

    Administrator Developer

    Thats vanilla behaviour as far as I can recall.
     
  16. joehot200

    Supporter

    I mean that if the server was already saved before the error occoured, your server would probably barely roll back 30 seconds.
     
  17. No, because the vanilla server isn't able to have 2 instances running on the same port.
     
  18. No, because I didn't notice there were two instances of the server running till after 24 hours
     
  19. joehot200

    Supporter

    Aha. Bad luck then.
     
  20. md_5

    Administrator Developer

    Fixed
     
    • Like Like x 1