The only downside with most dedicated gaming servers is the cost. If you need a 24/7 server or someone to manage it for you, you can’t avoid it. However, if you are self sufficient for setting up the gaming software, and only play certain games intermittently, your costs can be significantly reduced.
Let’s use Factorio as an example. To pay for a dedicated server it will cost around $5~10 per month, used or not. Now, if you are like me and play with friends and family only a few nights a month, that’s an unnecessary expense. Sure you can self host, but then everyone is dependent on a single person to have it up and running. Instead, I switched to using a Digital Ocean Droplet, and have paid less than a quarter this past month for an on demand gaming server.
Even if we played every night after work and weekends, it would only be $1 or $2 a month. You may be thinking “oh, you just turn off the droplet when you’re not using it!”, but alas, it is not that simple. A turned off droplet or server is still holding onto resources, so it still incurs cost, which is standard across all the hosting giants I looked into.
The trick on how to save cash? When you’re not playing, turn the droplet off, snapshot it, then destroy the droplet. When you want to play again, restore the snapshot to a new droplet. That way you are only paying server costs while it is running, then paying the super cheap snapshot storage the rest of the time.
This is painful to do by hand, but really easy with a helper script. (If you want to take it further, you could make it a website with access controls so only who you want could control it whenever they wanted.)
Digital Ocean Gaming Service (DOGS)
The code repo is available on github and the instructions are boringly standard.
git clone https://github.com/cdgriffith/dogs.git # Alternatively, just download and extract the zip file # https://github.com/cdgriffith/dogs/archive/master.zip # Create a venv if you are python savvy pip install requirements.txt cp config.yaml.example config.yaml # Update the config file to match your digital ocean settings python -m dogs
This script does have some prerequisites. You need to have a Digital Ocean account token, and will have to manually create and startup the server once before you can manage it via this script. (Pull Requests always considered if you want to ease that pain for others.)
When you do create the droplet you want, make sure to pick the smallest specs you think you will need. You can always upgrade to larger disk size, but cannot go back down to smaller. Also during this process, record the hostname which we will use as our server name in the config file.
You will also need your SSH key id, which are the digits at the very end of the public key. For example if the key ends with
rsa-key-20190721 the ssh id is
20190721. You can always find this info in the Accounts > Security section as well by selecting a key and hitting “Edit”.
Also if you hook a firewall up to the droplet you will also need that ID, which can you retrieve via the API.
DOGS Server Config
When you got all that info, add it to the
token: <your 64 character hex string> servers: ubuntu-1804-factorio: region: nyc1 size: s-1vcpu-2gb firewall_id: <unique hex string separated by dashes> snapshot_max: 2 ssh_key: <8 digits from end of ssh public cert>
Again, to run you just need to be in the dogs directory and run
python -m dogs.
Binary (EXE) files
If you want to package it into an easy to use
exe (can also modify for mac or linux binaries), just use the included build scripts.
# Windows specific requirements, otherwise just install 'pyinstaller' pip install -r requirements-build.txt python dogs\build.py
And now you should have a super handy
dogs.exe in the
dist directory. Don’t forget to keep your
config.yaml in the same directory as it!
Gaming Setup Scripts
I have a directory to put files for setting up and updating game servers. Right now I only have factorio, but feel free to add your own, a PR would be very appreciated! All you need is a way to near automatically create / install the service and a way to have it auto start (in my example using systemd for standard Ubuntu servers)
Check the scripts out on github.