Inspiration

I'm part of a gaming group known as 3Ra Gaming. Currently their primary game is Factorio. We wanted better integration between our Factorio servers and our Discord server.

What it does

You are able to start and stop servers from a webpage. The webpage also shows the server console so mods can watch for errors. This webpage was already built. My goal was to build the backend, what happens when the start and stop buttons were pressed. As an added benefit of using my management program, it allows chat to be sent between the servers and the Discord. This allows moderators to watch chat and manage players without actually being in-game.

How I built it

The system is multi-threaded, coded in C. It starts, launches the Discord bot (a separate program written in NodeJS), and watches for an input from the webserver. Each input will contain a unique server ID followed by a command (start/stop). Upon starting a server, the STDIN and STDOUT of the server are redirected into pipes. A new thread is created to watch the pipe coming from the server. Upon detecting certain key signals, it will perform certain actions. Pipes leading to each server are locked behind a mutex for thread safety.

Challenges I ran into

My biggest challenge was figured out how to detect chat from multiple servers at once. That led to the inclusion of threads. Detecting chat was a different story. Factorio gives almost no control over its chat system. In order to detect chat messages, I had to learn to watch for the Factorio specific signals while also filtering out false positives.

Accomplishments that I'm proud of

I'm proud of this entire system. It's my biggest project, and it took a lot of work.

What I learned

This was my first real experience with threading. I learned a lot about the intricacies of C. I also learned NodeJS existed, and I really enjoy that.

What's next for Factorio Server Management

Most of the changes are taking place in the bot, usually just optimizations and new management commands. There is one member talking about converting the management system from C to Python, however, so that may be interesting.

Built With

Share this project:

Updates