javanetwork-programmingkryonetonline-game

How to reliably deploy a game server jar to a machine?


Well i have a game server now up and running on my local development machine but i want to deploy it to a real servermachine. The easiest way would be to just transfer the jar file to the server and run it with java -jar server.jar. But i want to reliably deploy this jar to a server and keep it running like a daemon. The above command terminates if the server.jar crashes or it runs out of memory but i does not restart the server. Second i want it to be deployable to multiple physical servers. So the server.jar is startet on many physical machines and keep running as daemons.

I thought about running the server inside a servlet in Java EE but i think that would not work because Java EE requires you application does not create a socket by itself. And because i use kryonet as a networking library i cant prevent my app from doing it/i have no idea how to overcome that issue.

Is there any way i can do what i wanted to do? Maybe any application suggestions or frameworks build for this task?

Thank you


Solution

  • In general, because I'm not that familiar with java, the easiest way would be to handle ur problem by the OS of the server. As an example if ur application tends to crash at some point, u could watch with the OS a task, and if the task crashed simply start it again.

    The next step would be to code ur own "launcher" which does basically the same as the os, but in a more controlled way.

    To ur second question, honestly i do not understand what u mean. Every application can be fired up multiple times. So on 1 physical machine having more of ur servers running would be no problem (2 ways u deal with port allocation or u distribute a config file). If u want to deploy ur server on many physical machines where should occur any problem? Sr i don't udnerstand this question.

    In general to deploy a server, u need a install aka readme for the admins, and it should only contain dependencies, ur not allowed to distribute and one or more settings files to configure ur server. Also u can put in *.sh script to launch ur server.jar with the correct settings, or a *.bat for windows. If u have a launcher keep in mind it should be 100% setting dependent, so admins can control everything.

    That's it for general. Sr if this was not java specific, but honestly i do not know if such a subject can even be language specific. It's too basic for this.