MovingBlocks / FacadeServer

A headless facade that acts as a game host and provides web-based administration. Automation category: Terasology Facade. See https://forum.terasology.org/threads/facadeserver-headless-server-with-web-interface.1906
Apache License 2.0
4 stars 11 forks source link

Run the game engine #1

Closed gianluca-nitti closed 7 years ago

gianluca-nitti commented 7 years ago

For this first pull request I added the code to make this an actual engine facade. The engine runs on the main thread, while the Jetty web server runs on separate threads. Lots of "inspiration" and parts of code come from the standard PC facade. Here is how I set up my workspace, hoping it's the correct way (it should be according to the wiki instructions for facades):

Put shortly, to test this branch you can follow this process:

(*) about the Gradle configuration: I made some tweaks to the build.gradle according to the other facades, to setup a basic server configuration; it all works but I'm not sure if it's the correct way and how to correctly handle packaging/distribution. Also, I added two command line arguments, one to set the engine data directory and the other for the game server port. I'm not sure if the web server port too should be settable via a command line switch, for the moment I didn't change the existing code which sets it according to the PORT environment variable.

Maybe we can also improve these logistics details later if necessary, I focused on setting up a working development environment since I'm a bit late on the timeline.

Running the project as a facade introduced some issues with paths, because when you run via gradlew facades:Server:run the working directory of the program is the root repository and not the root of the facade, so at the moment you get 404s if you try to access localhost:8080/; I fixed the path for the logs using the engine's LoggingContext, so they are correctly served at localhost:8080/logs. In my opinion we could put the static web files in an appropriate subdirectory of src/main/resources/ but I think this will be relevant when I'll work on the frontend; my main goal at the moment is setting up the authentication API.

skaldarnar commented 7 years ago

@Cervator might want to have a quick look at the changes to build.gradle...

Cervator commented 7 years ago

Belated note about the build.gradle (feel free to ping me on Slack for anything important - I've got 4k unread GitHub notifications...): I'm fine with it here. Some bits are out of date but I've forked this to the test org Nanoware and pulled it locally to my Gradle redo workspace so I can include it at some point in the new stuff :-)