mc-server-manager/README.md

52 lines
2.2 KiB
Markdown

# mc-server-manager
Simple web server where players can see a list of available servers, player
counts, and request to turn on a server if they have a passcode.
It consists of two components: a web server, and an agent program that runs on
the minecraft server hardware itself.
## Web Server
The web server's responsibility is to show the latest server status information
and provide a way for players to request to turn on a server.
The server is built using [handy-http](https://github.com/andrewlalis/handy-httpd).
In addition to serving the web app from the associated `app` directory, the
following API endpoints are defined:
* POST `/api/servers` - for the agent to send the latest server status info.
* GET `/api/servers` - for clients to fetch the latest server status.
* POST `/api/servers/:id/requests` - for clients to request a server startup.
* GET `/api/server-requests` - for the agent to get a list of requested servers.
### Deployment
This application is deployed to run under a reverse proxy, like Nginx. Call the
`deploy-web.sh` script to deploy it to Andrew's main server.
## Agent
The agent will periodically inspect the status of all servers, and send that
data to the web server. The agent will also automatically shutdown servers
that have been inactive for more than 15 minutes.
More precisely, the agent will activate periodically, and each time perform the
following activites:
* Send the latest server status information to the web server.
* Use an *idle-tracker* file to determine the amount of time a server has been
*idle* (on, with no players active).
* If the server is idle, but doesn't yet have a tracker file, one is created.
* If the server has at least one player, any existing tracker file is removed.
* If the server is idle and there's a tracker file present, and the tracker
file is at least 15 minutes old, then the server is shut down.
* Get the list of requested servers to start from the web, and start each server.
### Deployment
This agent is simply deployed to the physical server where the minecraft
servers are installed, and it is linked as a SystemD service (but not enabled),
and then a SystemD timer is activated to trigger it to run every so often.
Run `deploy-agent.sh` to deploy the agent to the server.