Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Ubuntu instructions #142

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 18 additions & 19 deletions source/contributed/ps_ubuntu.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
---
title: Private server on Ubuntu using MongoDB and Redis
contributed:
name: tedivm
link: https://github.com/tedivm
date: 2018-02-07
name: tedivm
link: https://github.com/tedivm
date: 2018-02-07
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This formatting has meaning- this blob is essentially yaml, so when you remove those spaces you're turning these variables from being underneath the contributed key to being top level variables.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. Will fix and get out the no spray for VS Code

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this is just tabs being replaced by spaces. They are still indented two times in and is valid YAML:

title: Private server on Ubuntu using MongoDB and Redis
contributed:
  name: tedivm
  link: https://github.com/tedivm
  date: 2018-02-07

---

The Screeps engine is [Open Source](https://github.com/screeps/screeps), allowing people to run Private Servers on their own. The Steam Client even provides a tool to make launching private servers easier.

For players who want to run a headless server (one without a desktop or windows system, such as when running on Linode or AWS) a little more work is needed to get a reliable server, especially since the built in LokiJS engine does not scale well over time. This tutorial will guide you through installing Screeps in dedicated environment with MongoDB and redis.


## Prerequisites

### Server

This article assumes the user is running Ubuntu 16. It is recommended that the machine have at least two cores and 2gb of ram, although for single players and a couple of bots a one core 2gb machine will work with reasonable tick speeds.
This article assumes the user is running at least Ubuntu 16. It is recommended that the machine have at least two cores and 2gb of ram, although for single players and a couple of bots a one core 2gb machine will work with reasonable tick speeds.

As the system tends to be very CPU intensive it is recommended that you avoid "burstable" servers that don't provide constant cpu, such as the AWS t2 line.


### Build Tools

The following steps will need some common build and development tools, which we'll install here.
Expand All @@ -28,16 +26,22 @@ The following steps will need some common build and development tools, which we'
sudo apt install -y build-essential tcl git
```


### Install Node

The main world runs on Node8, but Ubuntu only provides an older version of Node6. Fortunately there is another apt repository we can use to get the most up to date versions.
The main world runs on Node10, but Ubuntu often provides older versions of Node. Fortunately there is another apt repository we can use to get the most up to date versions.

For Ubuntu 16 through 18:

```shell
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt install -y nodejs
```

For Ubuntu 19, Node10 is already default so just run:

```shell
sudo apt install -y nodejs
```

### Install Mongo

Expand All @@ -62,7 +66,6 @@ sudo systemctl start mongod
sudo systemctl enable mongod
```


### Install redis

Like the Mongo example above the distro version of redis is extremely outdated, but in this case there is a PPA available rather than an official apt repository for the project. This PPA is well maintained and has even been "blessed" by the redis developers.
Expand All @@ -78,7 +81,6 @@ sudo apt install redis-server

That's it! The redis server is remarkably simple and the apt package takes care of making sure it stays running.


## Screeps Server

### Create Screeps User
Expand Down Expand Up @@ -110,21 +112,19 @@ npx screeps init

The `init` call creates the configuration for your server in `.screepsrc`. You should read through this file, which is pretty well documented, but the only things you will likely want to change are `runners_cnt` and `processors_cnt`. On a smaller system (two cores) you'll want to set these to the number of processor cores available, but on larger systems you may want to leave a core or two free for use by MongoDB. If you want to run multiple worlds on the same server you should make sure to limit each server so their total combined `runners_cnt` and total combined `processors_cnt` values do not exceed the number of processors on the system.


### Install Server Mods

There are a few mods we'll be installing to enable the new backend and make the server easier to use and manage.

* [screepsmod-mongo](https://github.com/ScreepsMods/screepsmod-mongo) replaces the LokiJS based storage with a mongodb and redis solution.
* [screepsmod-auth](https://github.com/ScreepsMods/screepsmod-auth) allows players to set a password that can be used to log into the server with third party tools.
* [screepsmod-tickrate](https://github.com/ScreepsMods/screepsmod-tickrate) lets the server admin modify the minimum tick rate on the fly from the screeps cli tool.
* [screepsmod-admin-utils](https://github.com/ScreepsMods/screepsmod-admin-utils) adds some useful functions to the screeps cli.
* [screepsmod-features](https://github.com/ScreepsMods/screepsmod-features) exposes a list of features supported by the server.
- [screepsmod-mongo](https://github.com/ScreepsMods/screepsmod-mongo) replaces the LokiJS based storage with a mongodb and redis solution.
- [screepsmod-auth](https://github.com/ScreepsMods/screepsmod-auth) allows players to set a password that can be used to log into the server with third party tools.
- [screepsmod-admin-utils](https://github.com/ScreepsMods/screepsmod-admin-utils) adds some useful functions to the screeps cli including letting the server admin modify the minimum tick rate on the fly from the screeps cli tool.
- [screepsmod-features](https://github.com/ScreepsMods/screepsmod-features) exposes a list of features supported by the server.

We can install all of these at once with a simple command (still running as the user `screeps`).

```shell
npm install screepsmod-mongo screepsmod-auth screepsmod-tickrate screepsmod-admin-utils screepsmod-features
npm install screepsmod-mongo screepsmod-auth screepsmod-admin-utils screepsmod-features
```

Then just confirm that the `mods.json` file looks like this-
Expand All @@ -134,7 +134,6 @@ Then just confirm that the `mods.json` file looks like this-
"mods": [
"node_modules/screepsmod-mongo/index.js",
"node_modules/screepsmod-auth/index.js",
"node_modules/screepsmod-tickrate/index.js",
"node_modules/screepsmod-admin-utils/index.js",
"node_modules/screepsmod-features/index.js"
],
Expand Down