Split up into multiple packages with Lerna
Split up codebase into the packages @clsterio/lib, @clusterio/master, @clusterio/slave, and @clusterio/ctl using lerna to manage them. This will allow deployment to use only the parts needed reducing install size, and better separate the code into shared library, master, slave and control.
No files matched your search
@@ -0,0 +1 @@
|
|||||||
|
packages/master/static
|
||||||
@@ -28,7 +28,7 @@ dist/
|
|||||||
# Autogenerated docs output
|
# Autogenerated docs output
|
||||||
/docs/api
|
/docs/api
|
||||||
|
|
||||||
node_modules/*
|
node_modules
|
||||||
|
|
||||||
Factorio*
|
Factorio*
|
||||||
/factorio
|
/factorio
|
||||||
@@ -41,7 +41,7 @@ Factorio*
|
|||||||
package-lock.json
|
package-lock.json
|
||||||
mod_cache.json
|
mod_cache.json
|
||||||
static/export
|
static/export
|
||||||
static/external
|
packages/master/static/external
|
||||||
saves
|
saves
|
||||||
/temp/
|
/temp/
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ before_install:
|
|||||||
- tar -xf factorio.tar.gz
|
- tar -xf factorio.tar.gz
|
||||||
- npm install -g codecov
|
- npm install -g codecov
|
||||||
script:
|
script:
|
||||||
- node build-mod --bump-patch --factorio-version 0.18 --output-dir sharedMods
|
- npx lerna bootstrap
|
||||||
|
- node packages/lib/build_mod --bump-patch --factorio-version 0.18 --output-dir sharedMods
|
||||||
- curl -o sharedMods/subspace_storage_1.99.1.zip -L https://github.com/clusterio/factorioClusterioMod/releases/download/1.99.1/subspace_storage_1.99.1.zip
|
- curl -o sharedMods/subspace_storage_1.99.1.zip -L https://github.com/clusterio/factorioClusterioMod/releases/download/1.99.1/subspace_storage_1.99.1.zip
|
||||||
- npm run-script ci-cover
|
- npm run-script ci-cover
|
||||||
- cat temp/test/integration/log.txt
|
- cat temp/test/integration/log.txt
|
||||||
|
|||||||
@@ -105,12 +105,13 @@ supported on EOL Ubuntu releases so make sure you're on a recent release of Ubun
|
|||||||
Master and all slaves:
|
Master and all slaves:
|
||||||
|
|
||||||
wget -qO - https://deb.nodesource.com/setup_12.x | sudo -E bash -
|
wget -qO - https://deb.nodesource.com/setup_12.x | sudo -E bash -
|
||||||
sudo apt install -y nodejs python-dev git build-essential
|
sudo apt install -y nodejs
|
||||||
git clone -b master https://github.com/clusterio/factorioClusterio.git
|
mkdir clusterio
|
||||||
cd factorioClusterio
|
cd clusterio
|
||||||
|
npm init -y
|
||||||
|
npm install @clusterio/master @clusterio/slave @clusterio/ctl
|
||||||
wget -O factorio.tar.gz https://www.factorio.com/get-download/latest/headless/linux64
|
wget -O factorio.tar.gz https://www.factorio.com/get-download/latest/headless/linux64
|
||||||
tar -xf factorio.tar.gz
|
tar -xf factorio.tar.gz
|
||||||
npm install --only=production
|
|
||||||
|
|
||||||
downloads and installs nodejs, git and clusterio. To specify a version, change "latest" in the link to a version number like 0.14.21.
|
downloads and installs nodejs, git and clusterio. To specify a version, change "latest" in the link to a version number like 0.14.21.
|
||||||
|
|
||||||
@@ -136,30 +137,19 @@ The -v flag is used to specify the instance directory. Your instances (save file
|
|||||||
**Warning**: These instructions are for the unstable master version and is not
|
**Warning**: These instructions are for the unstable master version and is not
|
||||||
recommended for use, see [the 1.2.x branch][1.2.x] for how to install the stable version.
|
recommended for use, see [the 1.2.x branch][1.2.x] for how to install the stable version.
|
||||||
|
|
||||||
Clusterio is built up of multiple parts. Here is a quick guide:
|
|
||||||
|
|
||||||
Master = master.js
|
|
||||||
|
|
||||||
Server host (Slave) = slave.js + factorio server
|
|
||||||
|
|
||||||
Game Client = The people connecting to the server
|
|
||||||
|
|
||||||
**Requirements**
|
**Requirements**
|
||||||
|
|
||||||
download and install nodeJS 12 from http://nodejs.org. Clusterio runs on Node.js v12 and
|
download and install nodeJS 12 from http://nodejs.org. Clusterio runs on Node.js v12 and
|
||||||
up, v11.13.0+ and v10.16.0+.
|
up, v11.13.0+ and v10.16.0+.
|
||||||
|
|
||||||
download and install git from https://git-scm.com/
|
|
||||||
|
|
||||||
reboot when you are done, then proceed to the next steps. *reboots matter*
|
|
||||||
|
|
||||||
**Master**
|
**Master**
|
||||||
|
|
||||||
1. Open PowerShell or Command prompt in the directory you want to install to and run the following commands.
|
1. Open PowerShell or Command prompt in the directory you want to install to and run the following commands.
|
||||||
|
|
||||||
git clone -b master https://github.com/clusterio/factorioClusterio
|
mkdir clusterio
|
||||||
cd factorioClusterio
|
cd clusterio
|
||||||
npm install --only=production
|
npm init -y
|
||||||
|
npm install @clusterio/master @clusterio/slave @clusterio/ctl
|
||||||
|
|
||||||
2. Obtain Factorio by either of these two methods:
|
2. Obtain Factorio by either of these two methods:
|
||||||
|
|
||||||
@@ -198,8 +188,8 @@ Before you can manage the cluster you need to bootstrap an admin account
|
|||||||
for it. Replace `<username>` with your Factorio username (do not make
|
for it. Replace `<username>` with your Factorio username (do not make
|
||||||
up a new username here).
|
up a new username here).
|
||||||
|
|
||||||
node master bootstrap create-admin <username>
|
npx clusteriomaster bootstrap create-admin <username>
|
||||||
node master bootstrap create-ctl-config <username>
|
npx clusteriomaster bootstrap create-ctl-config <username>
|
||||||
|
|
||||||
The first command creates a user account with the given name and
|
The first command creates a user account with the given name and
|
||||||
promotes it to a cluster admin. The second one sets up a
|
promotes it to a cluster admin. The second one sets up a
|
||||||
@@ -213,7 +203,7 @@ It's necessary to run the master server in order for anything to work.
|
|||||||
Once you've completed the setup run the following command to start it
|
Once you've completed the setup run the following command to start it
|
||||||
up:
|
up:
|
||||||
|
|
||||||
node master run
|
npx clusteriomaster run
|
||||||
|
|
||||||
|
|
||||||
### Slaves
|
### Slaves
|
||||||
@@ -223,7 +213,7 @@ master server. In order for slaves to connect to the master server they
|
|||||||
need a valid authentication token, you can create a slave config with
|
need a valid authentication token, you can create a slave config with
|
||||||
a valid token with the following command.
|
a valid token with the following command.
|
||||||
|
|
||||||
node clusterctl slave create-config --name Local --generate-token
|
npx clusterctl slave create-config --name Local --generate-token
|
||||||
|
|
||||||
This will write a new `config-slave.json` file in the current directory
|
This will write a new `config-slave.json` file in the current directory
|
||||||
(you can change the location with the `--output` option) with the name,
|
(you can change the location with the `--output` option) with the name,
|
||||||
@@ -232,13 +222,13 @@ the config for a remote slave you will need to have set the
|
|||||||
`master.external_address` option to the URL the master server can be
|
`master.external_address` option to the URL the master server can be
|
||||||
reached on.
|
reached on.
|
||||||
|
|
||||||
You can list the config of a slave on the slave itself with the `node
|
You can list the config of a slave on the slave itself with the `npx
|
||||||
slave config list` command. Use `node slave config --help` for more
|
clusterioslave config list` command. Use `npx clusterioslave config
|
||||||
information.
|
--help` for more information.
|
||||||
|
|
||||||
Once the config is set up run the slave with
|
Once the config is set up run the slave with
|
||||||
|
|
||||||
node slave run
|
npx clusterioslave run
|
||||||
|
|
||||||
|
|
||||||
### Instances
|
### Instances
|
||||||
@@ -253,9 +243,9 @@ clusterctl control-config set` command:
|
|||||||
|
|
||||||
The basic operations to start a new instance is the following
|
The basic operations to start a new instance is the following
|
||||||
|
|
||||||
node clusterctl instance create "My instance"
|
npx clusterctl instance create "My instance"
|
||||||
node clusterctl instance assign "My instance" "Local"
|
npx clusterctl instance assign "My instance" "Local"
|
||||||
node clusterctl instance start "My instance"
|
npx clusterctl instance start "My instance"
|
||||||
|
|
||||||
The first line creates the instance configuration on the master server.
|
The first line creates the instance configuration on the master server.
|
||||||
The second assigns the instance to a slave which creates the instance
|
The second assigns the instance to a slave which creates the instance
|
||||||
@@ -264,7 +254,7 @@ third line starts the instance, which creates a new save if there are no
|
|||||||
save games present.
|
save games present.
|
||||||
|
|
||||||
There are many more commands available with clusterctl. See
|
There are many more commands available with clusterctl. See
|
||||||
`node clusterctl --help` for a full list of them.
|
`npx clusterctl --help` for a full list of them.
|
||||||
|
|
||||||
|
|
||||||
## Plugins
|
## Plugins
|
||||||
@@ -298,7 +288,3 @@ TLDR: the tested fix is:
|
|||||||
- select TCP and select specific local ports and type in the ports that you want to open (comma separated) and click next > 3 times
|
- select TCP and select specific local ports and type in the ports that you want to open (comma separated) and click next > 3 times
|
||||||
|
|
||||||
- give the rule a name (like 'web server' or something), give it a description (optionally) and click finish
|
- give the rule a name (like 'web server' or something), give it a description (optionally) and click finish
|
||||||
|
|
||||||
### Other fixes for other potential problems:
|
|
||||||
|
|
||||||
Sometimes the install fails. Try `node ./lib/npmPostinstall` to complete it.
|
|
||||||
@@ -49,9 +49,10 @@ Message
|
|||||||
|
|
||||||
There's two types of messages currently implemented apart from the
|
There's two types of messages currently implemented apart from the
|
||||||
Link builtin close message and that's Request and Event. The builtin
|
Link builtin close message and that's Request and Event. The builtin
|
||||||
messages are defined in [lib/link/messages.js](../lib/link/messages.js)
|
messages are defined in
|
||||||
and are attached to links via the attachAllMessages function, which is
|
[lib/link/messages.js](/package/lib/link/messages.js) and are attached
|
||||||
usally called in the Link subclass constructor.
|
to links via the attachAllMessages function, which is usally called in
|
||||||
|
the Link subclass constructor.
|
||||||
|
|
||||||
The messages define which links they are valid on and only attaches
|
The messages define which links they are valid on and only attaches
|
||||||
handlers for those links. There's also a forwarding mechanism for when
|
handlers for those links. There's also a forwarding mechanism for when
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ the startup, and the groups and their fields for disabled plugins will
|
|||||||
still be created.
|
still be created.
|
||||||
|
|
||||||
The built-in config groups and their fields are defined in
|
The built-in config groups and their fields are defined in
|
||||||
[/lib/config/definitions.js](lib/config/definitions.js) while plugins
|
[lib/config/definitions.js](/packages/lib/config/definitions.js) while
|
||||||
can add their own config groups to the `MasterConfigGroup` and
|
plugins can add their own config groups to the `MasterConfigGroup` and
|
||||||
`InstanceConfigGroup` properties of the `info.js` export using
|
`InstanceConfigGroup` properties of the `info.js` export using
|
||||||
subclasses of `PluginConfigGroup`. The plugin group has the enabled
|
subclasses of `PluginConfigGroup`. The plugin group has the enabled
|
||||||
field pre-defined on it, and it's used to enable/disable plugins.
|
field pre-defined on it, and it's used to enable/disable plugins.
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ Contents
|
|||||||
|
|
||||||
- [Workflow](#workflow)
|
- [Workflow](#workflow)
|
||||||
- [Starting a Feature Branch](#starting-a-feature-branch)
|
- [Starting a Feature Branch](#starting-a-feature-branch)
|
||||||
|
- [Setting up the Development Environment](#setting-up-the-development-environment)
|
||||||
- [Checking your code for errors](#checking-your-code-for-errors)
|
- [Checking your code for errors](#checking-your-code-for-errors)
|
||||||
- [Submitting a Pull Request](#submitting-a-pull-request)
|
- [Submitting a Pull Request](#submitting-a-pull-request)
|
||||||
- [Editing your Feature Branch](#editing-your-feature-branch)
|
- [Editing your Feature Branch](#editing-your-feature-branch)
|
||||||
@@ -56,6 +57,19 @@ from the main repository. Do not run `git pull upstream` it will mess
|
|||||||
thing up!
|
thing up!
|
||||||
|
|
||||||
|
|
||||||
|
### Setting up the Development Environment
|
||||||
|
|
||||||
|
The project is organized into several packages that are all managed
|
||||||
|
through Lerna. In order to get the development environment up and
|
||||||
|
running you will need to run the following commands:
|
||||||
|
|
||||||
|
npm install
|
||||||
|
npx lerna bootstrap
|
||||||
|
|
||||||
|
This installs dependencies needed by tests and links the packages up so
|
||||||
|
they work from the git work tree.
|
||||||
|
|
||||||
|
|
||||||
### Starting a Feature Branch
|
### Starting a Feature Branch
|
||||||
|
|
||||||
Development is done exclusively in feature branches. This means the
|
Development is done exclusively in feature branches. This means the
|
||||||
|
|||||||
@@ -11,12 +11,12 @@
|
|||||||
},
|
},
|
||||||
"source": {
|
"source": {
|
||||||
"include": [
|
"include": [
|
||||||
"master.js",
|
"packages/master/src/",
|
||||||
"slave.js",
|
"packages/master/master.js",
|
||||||
"clusterctl.js",
|
"packages/slave/slave.js",
|
||||||
"lib/",
|
"packages/ctl/clusterctl.js",
|
||||||
"plugins/",
|
"packages/lib/",
|
||||||
"routes.js"
|
"plugins/"
|
||||||
],
|
],
|
||||||
"excludePattern": "node_modules"
|
"excludePattern": "node_modules"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,16 +3,16 @@ Managing a Cluster
|
|||||||
|
|
||||||
Clusterio clusers are managed through the master server by using the
|
Clusterio clusers are managed through the master server by using the
|
||||||
`clusterctl` command line interface which is invoked by running
|
`clusterctl` command line interface which is invoked by running
|
||||||
`node clusterctl <command>` in the clusterio directory. This document
|
`npx clusterctl <command>` in the clusterio directory. This document
|
||||||
uses the shorthand `ctl> foo` to indicate `node clusterctl foo` should
|
uses the shorthand `ctl> foo` to indicate `npx clusterctl foo` should
|
||||||
be executed. Mandatory parameters are shown in `<angles bracket>` and
|
be executed. Mandatory parameters are shown in `<angles bracket>` and
|
||||||
optional pameters are in `[square brackets]`.
|
optional pameters are in `[square brackets]`.
|
||||||
|
|
||||||
Before `clusterctl` can be used it needs to be configured for the
|
Before `clusterctl` can be used it needs to be configured for the
|
||||||
cluster it will connect to. The easiest way to do this is to run
|
cluster it will connect to. The easiest way to do this is to run
|
||||||
`node master bootstrap create-ctl-config <username>` on the master
|
`npx clusteriomaster bootstrap create-ctl-config <username>` on the
|
||||||
server, which creates the necessary `config-control.json` for managing
|
master server, which creates the necessary `config-control.json` for
|
||||||
the cluster as the given user.
|
managing the cluster as the given user.
|
||||||
|
|
||||||
|
|
||||||
Slaves
|
Slaves
|
||||||
|
|||||||
@@ -230,8 +230,8 @@ there's [Requests](#requests). By convention message types ending in
|
|||||||
`*_event` are events. The data payload of an event consists solely of
|
`*_event` are events. The data payload of an event consists solely of
|
||||||
event specific properties.
|
event specific properties.
|
||||||
|
|
||||||
See [lib/link/messages.js](/lib/link/messages.js) for the recognized
|
See [lib/link/messages.js](/packages/lib/link/messages.js) for the
|
||||||
events and their contents.
|
recognized events and their contents.
|
||||||
|
|
||||||
|
|
||||||
Requests
|
Requests
|
||||||
@@ -245,8 +245,8 @@ replied to with a corresponding `*_response` message. If an error
|
|||||||
occured while processing the request an error response containing an
|
occured while processing the request an error response containing an
|
||||||
error property in the data payload is sent instead.
|
error property in the data payload is sent instead.
|
||||||
|
|
||||||
See [lib/link/messages.js](/lib/link/messages.js) for the recognized
|
See [lib/link/messages.js](/packages/lib/link/messages.js) for the
|
||||||
requests and their contents.
|
recognized requests and their contents.
|
||||||
|
|
||||||
### `*_response`
|
### `*_response`
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ The basic file structure of a plugin is the following.
|
|||||||
The most important file is the `info.js` file. Without it the plugin
|
The most important file is the `info.js` file. Without it the plugin
|
||||||
will not recognized by Clusterio. Here's an example of it:
|
will not recognized by Clusterio. Here's an example of it:
|
||||||
|
|
||||||
const link = require('lib/link'); // For messages
|
const link = require('@clusterio/lib/link'); // For messages
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: "foo_frobber",
|
name: "foo_frobber",
|
||||||
@@ -129,7 +129,7 @@ The plugin class should derive from its respective base class defined in
|
|||||||
`lib/plugin`. For example, to define a MasterPlugin class the following
|
`lib/plugin`. For example, to define a MasterPlugin class the following
|
||||||
code can be used:
|
code can be used:
|
||||||
|
|
||||||
const plugin = require('lib/plugin');
|
const plugin = require('@clusterio/lib/plugin');
|
||||||
|
|
||||||
class MasterPlugin extends plugin.BaseMasterPlugin {
|
class MasterPlugin extends plugin.BaseMasterPlugin {
|
||||||
async init() {
|
async init() {
|
||||||
@@ -147,7 +147,7 @@ code can be used:
|
|||||||
For the instance plugin it's exactly the same except "Master" is
|
For the instance plugin it's exactly the same except "Master" is
|
||||||
replaced with "Instance", and for the clusterctl plugin "Control" is
|
replaced with "Instance", and for the clusterctl plugin "Control" is
|
||||||
used. The available hooks that you can override are documented in the
|
used. The available hooks that you can override are documented in the
|
||||||
base class [in lib/plugin.js](../lib/plugin.js).
|
base class [in lib/plugin.js](/packages/lib/plugin.js).
|
||||||
|
|
||||||
It's best to avoid defining a constructor, but if you insist on defining
|
It's best to avoid defining a constructor, but if you insist on defining
|
||||||
one, forward all arguments to the base class. E.g.:
|
one, forward all arguments to the base class. E.g.:
|
||||||
@@ -173,7 +173,7 @@ take advantage of it by subclassing `PluginConfigGroup`, setting the
|
|||||||
and passing it as either `MasterConfigGroup` or `InstanceConfigGroup` in
|
and passing it as either `MasterConfigGroup` or `InstanceConfigGroup` in
|
||||||
the `info.js` export. For example in info.js:
|
the `info.js` export. For example in info.js:
|
||||||
|
|
||||||
const config = require("lib/config");
|
const config = require("@clusterio/lib/config");
|
||||||
|
|
||||||
class MasterConfigGroup extends config.PluginConfigGroup { }
|
class MasterConfigGroup extends config.PluginConfigGroup { }
|
||||||
MasterConfigGroup.groupName = "foo_frobber";
|
MasterConfigGroup.groupName = "foo_frobber";
|
||||||
@@ -550,7 +550,7 @@ from plugins optionally loaded at runtime on different computers.
|
|||||||
In its simplest form collecting data from plugins consists of defining
|
In its simplest form collecting data from plugins consists of defining
|
||||||
the metric and updating it somewhere in the plugin code. For example:
|
the metric and updating it somewhere in the plugin code. For example:
|
||||||
|
|
||||||
const { Counter } = require('lib/prometheus');
|
const { Counter } = require('@clusterio/lib/prometheus');
|
||||||
|
|
||||||
const fooMetric = new Counter(
|
const fooMetric = new Counter(
|
||||||
'clusterio_foo_frobber_foo_metric', "Measures the level of foo",
|
'clusterio_foo_frobber_foo_metric', "Measures the level of foo",
|
||||||
@@ -567,7 +567,7 @@ naming scheme.
|
|||||||
For metrics that are per-instance, you must define an `instance_id` label and
|
For metrics that are per-instance, you must define an `instance_id` label and
|
||||||
set it accordingly, for example:
|
set it accordingly, for example:
|
||||||
|
|
||||||
const { Counter } = require('lib/prometheus');
|
const { Counter } = require('@clusterio/lib/prometheus');
|
||||||
|
|
||||||
const barMetric = new Gauge(
|
const barMetric = new Gauge(
|
||||||
'clusterio_foo_frobber_bar_metric', "Bar instance level",
|
'clusterio_foo_frobber_bar_metric', "Bar instance level",
|
||||||
@@ -598,7 +598,7 @@ The control entrypoint for plugins allows you to extend clustectl with
|
|||||||
your own commands. The creation of custom commands typically starts
|
your own commands. The creation of custom commands typically starts
|
||||||
with defining a command tree for the plugin:
|
with defining a command tree for the plugin:
|
||||||
|
|
||||||
const { Command, CommandTree } = require("lib/command");
|
const { Command, CommandTree } = require("@clusterio/lib/command");
|
||||||
const fooFrobberCommands = new CommandTree({
|
const fooFrobberCommands = new CommandTree({
|
||||||
name: "foo-frobber", description: "Foo Frobber Plugin commands"
|
name: "foo-frobber", description: "Foo Frobber Plugin commands"
|
||||||
});
|
});
|
||||||
@@ -641,7 +641,7 @@ for how to define the messages that can be sent to the master.
|
|||||||
To have the command tree become part of clusterctl it needs to be added
|
To have the command tree become part of clusterctl it needs to be added
|
||||||
to the rootCommand tree in `addCommands` callback of the Control plugin:
|
to the rootCommand tree in `addCommands` callback of the Control plugin:
|
||||||
|
|
||||||
const plugin = require("lib/plugin");
|
const plugin = require("@clusterio/lib/plugin");
|
||||||
|
|
||||||
class ControlPlugin extends plugin.BaseControlPlugin {
|
class ControlPlugin extends plugin.BaseControlPlugin {
|
||||||
async addCommands(rootCommand) {
|
async addCommands(rootCommand) {
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"packages": [
|
||||||
|
"packages/*"
|
||||||
|
],
|
||||||
|
"version": "2.0.0-alpha0"
|
||||||
|
}
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "lib",
|
|
||||||
"description": "Internal library for factorioClusterio"
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,18 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "clusterio",
|
"name": "root",
|
||||||
"version": "2.0.0-alpha",
|
"private": true,
|
||||||
"description": "Interserver communication for factorio",
|
|
||||||
"repository": "https://github.com/clusterio/factorioClusterio",
|
|
||||||
"main": "master.js",
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "mocha --exit --check-leaks -R spec --recursive test plugins/*/test",
|
"test": "mocha --exit --check-leaks -R spec --recursive test plugins/*/test",
|
||||||
"fast-test": "FAST_TEST=y npm test",
|
"fast-test": "FAST_TEST=y npm test",
|
||||||
"cover": "nyc npm test",
|
"cover": "nyc npm test",
|
||||||
"fast-cover": "FAST_TEST=y nyc npm test",
|
"fast-cover": "FAST_TEST=y nyc npm test",
|
||||||
"ci-cover": "nyc --reporter=lcovonly npm run-script test",
|
"ci-cover": "nyc --reporter=lcovonly npm run-script test",
|
||||||
"lint": "eslint \"*.js\" lib plugins test",
|
"lint": "eslint \"*.js\" packages plugins test",
|
||||||
"docs": "jsdoc --configure docs/jsdoc.json",
|
"docs": "jsdoc --configure docs/jsdoc.json",
|
||||||
"install": "node lib/npmPostinstall",
|
|
||||||
"bundle-dependencies": "bundle-dependencies"
|
"bundle-dependencies": "bundle-dependencies"
|
||||||
},
|
},
|
||||||
"nyc": {
|
"nyc": {
|
||||||
@@ -21,49 +17,24 @@
|
|||||||
"plugins/*/test/**"
|
"plugins/*/test/**"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"keywords": [
|
|
||||||
"factorio"
|
|
||||||
],
|
|
||||||
"author": "Danielv123",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.16 <11 || >= 11.13"
|
"node": ">=10.16 <11 || >= 11.13"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
|
||||||
"as-table": "^1.0.31",
|
|
||||||
"body-parser": "^1.18.2",
|
|
||||||
"chalk": "^3.0.0",
|
|
||||||
"compression": "^1.7.2",
|
|
||||||
"cookie-parser": "^1.4.3",
|
|
||||||
"ejs": "^2.5.7",
|
|
||||||
"express": "^4.16.2",
|
|
||||||
"express-fileupload": "1.2.0",
|
|
||||||
"fs-extra": "^8.1.0",
|
|
||||||
"ini": "^1.3.5",
|
|
||||||
"jimp": "^0.12.1",
|
|
||||||
"jsonwebtoken": "^8.2.1",
|
|
||||||
"jszip": "^3.2.2",
|
|
||||||
"lib": "file:./lib",
|
|
||||||
"moment": "^2.22.2",
|
|
||||||
"needle": "^2.4.0",
|
|
||||||
"node-factorio-api": "^0.3.8",
|
|
||||||
"node-forge": "^0.10.0",
|
|
||||||
"phin": "^3.4.1",
|
|
||||||
"pidusage": "^2.0.18",
|
|
||||||
"rcon-client": "^4.2.0",
|
|
||||||
"request": "^2.83.0",
|
|
||||||
"semver": "^7.1.1",
|
|
||||||
"set-blocking": "^2.0.0",
|
|
||||||
"ws": "^7.2.3",
|
|
||||||
"yargs": "^14.2.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@clusterio/ctl": "file:./packages/ctl",
|
||||||
|
"@clusterio/lib": "file:./packages/lib",
|
||||||
|
"@clusterio/master": "file:packages/master",
|
||||||
|
"@clusterio/slave": "file:./packages/slave",
|
||||||
"eslint": "^7.2.0",
|
"eslint": "^7.2.0",
|
||||||
|
"fs-extra": "^8.1.0",
|
||||||
"html5-validator": "^1.2.1",
|
"html5-validator": "^1.2.1",
|
||||||
"jsdoc": "^3.6.3",
|
"jsdoc": "^3.6.3",
|
||||||
"klaw": "^3.0.0",
|
"jsonwebtoken": "^8.2.1",
|
||||||
|
"jszip": "^3.2.2",
|
||||||
|
"lerna": "^3.22.1",
|
||||||
"mocha": "^6.2.0",
|
"mocha": "^6.2.0",
|
||||||
"mocha.parallel": "^0.15.5",
|
"mocha.parallel": "^0.15.5",
|
||||||
"nyc": "^14.1.1"
|
"nyc": "^14.1.1",
|
||||||
|
"phin": "^3.4.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,21 +1,23 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command line interface for controlling a Clusterio cluster
|
* Command line interface for controlling a Clusterio cluster
|
||||||
* @module
|
* @module
|
||||||
*/
|
*/
|
||||||
"use strict";
|
"use strict";
|
||||||
const jwt = require("jsonwebtoken");
|
|
||||||
const fs = require("fs-extra");
|
const fs = require("fs-extra");
|
||||||
const yargs = require("yargs");
|
const yargs = require("yargs");
|
||||||
const version = require("./package").version;
|
const version = require("./package").version;
|
||||||
const asTable = require("as-table").configure({ delimiter: " | " });
|
const asTable = require("as-table").configure({ delimiter: " | " });
|
||||||
const chalk = require("chalk");
|
const chalk = require("chalk");
|
||||||
const events = require("events");
|
const events = require("events");
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
const link = require("lib/link");
|
const link = require("@clusterio/lib/link");
|
||||||
const errors = require("lib/errors");
|
const errors = require("@clusterio/lib/errors");
|
||||||
const config = require("lib/config");
|
const config = require("@clusterio/lib/config");
|
||||||
const plugin = require("lib/plugin");
|
const plugin = require("@clusterio/lib/plugin");
|
||||||
const command = require("lib/command");
|
const command = require("@clusterio/lib/command");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -608,7 +610,9 @@ async function startControl() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let { ControlPlugin } = require(`./plugins/${pluginInfo.name}/${pluginInfo.controlEntrypoint}`);
|
// XXX Does not work on Windows
|
||||||
|
let pluginPath = path.relative(__dirname, path.join("plugins", pluginInfo.name));
|
||||||
|
let { ControlPlugin } = require(path.join(pluginPath, pluginInfo.controlEntrypoint));
|
||||||
let controlPlugin = new ControlPlugin(pluginInfo);
|
let controlPlugin = new ControlPlugin(pluginInfo);
|
||||||
controlPlugins.set(pluginInfo.name, controlPlugin);
|
controlPlugins.set(pluginInfo.name, controlPlugin);
|
||||||
await controlPlugin.init();
|
await controlPlugin.init();
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"name": "@clusterio/ctl",
|
||||||
|
"description": "Clusterio command line management tool",
|
||||||
|
"author": "Hornwitser",
|
||||||
|
"license": "MIT",
|
||||||
|
"version": "2.0.0-alpha0",
|
||||||
|
"main": "clusterctl.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"clusterctl": "./clusterctl.js"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"factorio"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.16 <11 || >= 11.13"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@clusterio/lib": "=2.0.0-alpha0",
|
||||||
|
"as-table": "^1.0.31",
|
||||||
|
"chalk": "^3.0.0",
|
||||||
|
"fs-extra": "^8.1.0",
|
||||||
|
"yargs": "^14.2.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,8 +7,8 @@
|
|||||||
* @module
|
* @module
|
||||||
*/
|
*/
|
||||||
"use strict";
|
"use strict";
|
||||||
const link = require("lib/link");
|
const link = require("@clusterio/lib/link");
|
||||||
const errors = require("lib/errors");
|
const errors = require("@clusterio/lib/errors");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a command that can be runned by clusterctl
|
* Represents a command that can be runned by clusterctl
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
const events = require("events");
|
const events = require("events");
|
||||||
const util = require("util");
|
const util = require("util");
|
||||||
|
|
||||||
const { basicType } = require("lib/helpers");
|
const { basicType } = require("@clusterio/lib/helpers");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
const fs = require("fs-extra");
|
const fs = require("fs-extra");
|
||||||
|
|
||||||
const { basicType } = require("lib/helpers");
|
const { basicType } = require("@clusterio/lib/helpers");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -6,7 +6,7 @@ const ini = require("ini");
|
|||||||
const Jimp = require("jimp");
|
const Jimp = require("jimp");
|
||||||
const JSZip = require("jszip");
|
const JSZip = require("jszip");
|
||||||
|
|
||||||
const buildMod = require("../../build-mod");
|
const buildMod = require("@clusterio/lib/build_mod");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate the export mod needed for exportData
|
* Generate the export mod needed for exportData
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
"use strict";
|
"use strict";
|
||||||
module.exports = {
|
module.exports = {
|
||||||
...require("lib/factorio/export"),
|
...require("./export"),
|
||||||
...require("lib/factorio/patch"),
|
...require("./patch"),
|
||||||
...require("lib/factorio/server"),
|
...require("./server"),
|
||||||
};
|
};
|
||||||
@@ -7,7 +7,7 @@ const jszip = require("jszip");
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
const semver = require("semver");
|
const semver = require("semver");
|
||||||
|
|
||||||
const hash = require("lib/hash");
|
const hash = require("@clusterio/lib/hash");
|
||||||
|
|
||||||
|
|
||||||
const knownScenarios = {
|
const knownScenarios = {
|
||||||
@@ -9,7 +9,7 @@ const crypto = require("crypto");
|
|||||||
|
|
||||||
const ini = require("ini");
|
const ini = require("ini");
|
||||||
const rconClient = require("rcon-client");
|
const rconClient = require("rcon-client");
|
||||||
const errors = require("lib/errors");
|
const errors = require("@clusterio/lib/errors");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3,8 +3,8 @@
|
|||||||
const events = require("events");
|
const events = require("events");
|
||||||
const WebSocket = require("ws");
|
const WebSocket = require("ws");
|
||||||
|
|
||||||
const schema = require("lib/schema");
|
const schema = require("@clusterio/lib/schema");
|
||||||
const errors = require("lib/errors");
|
const errors = require("@clusterio/lib/errors");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
"use strict";
|
"use strict";
|
||||||
module.exports = {
|
module.exports = {
|
||||||
...require("lib/link/link"),
|
...require("./link"),
|
||||||
...require("lib/link/messages"),
|
...require("./messages"),
|
||||||
...require("lib/link/connectors"),
|
...require("./connectors"),
|
||||||
};
|
};
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
// Implementation of Link class
|
// Implementation of Link class
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const schema = require("lib/schema");
|
const schema = require("@clusterio/lib/schema");
|
||||||
const errors = require("lib/errors");
|
const errors = require("@clusterio/lib/errors");
|
||||||
const messages = require("lib/link/messages");
|
const messages = require("./messages");
|
||||||
|
|
||||||
// Some definitions for the terminology used here:
|
// Some definitions for the terminology used here:
|
||||||
// link: Either side of a master - client connection
|
// link: Either side of a master - client connection
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
// Message definitions for links
|
// Message definitions for links
|
||||||
"use strict";
|
"use strict";
|
||||||
const schema = require("lib/schema");
|
const schema = require("@clusterio/lib/schema");
|
||||||
const errors = require("lib/errors");
|
const errors = require("@clusterio/lib/errors");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a message that can be sent over the link
|
* Represents a message that can be sent over the link
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"name": "@clusterio/lib",
|
||||||
|
"description": "Shared library for Clusterio",
|
||||||
|
"version": "2.0.0-alpha0",
|
||||||
|
"repository": "https://github.com/clusterio/factorioClusterio",
|
||||||
|
"license": "MIT",
|
||||||
|
"keywords": [
|
||||||
|
"factorio"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.16 <11 || >= 11.13"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"fs-extra": "^8.1.0",
|
||||||
|
"ini": "^1.3.5",
|
||||||
|
"jimp": "^0.12.1",
|
||||||
|
"jsonwebtoken": "^8.2.1",
|
||||||
|
"jszip": "^3.2.2",
|
||||||
|
"klaw": "^3.0.0",
|
||||||
|
"node-forge": "^0.10.0",
|
||||||
|
"rcon-client": "^4.2.0",
|
||||||
|
"semver": "^7.1.1",
|
||||||
|
"ws": "^7.2.3",
|
||||||
|
"yargs": "^14.2.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
const fs = require("fs-extra");
|
const fs = require("fs-extra");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
const errors = require("lib/errors");
|
const errors = require("@clusterio/lib/errors");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -392,7 +392,9 @@ async function loadPluginInfos(baseDir) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Note: Require path is relative to this module
|
// Note: Require path is relative to this module
|
||||||
pluginInfo = require(path.posix.join("..", baseDir, pluginDir, "info"));
|
// XXX Does not work on Windows
|
||||||
|
let pluginPath = path.relative(__dirname, path.join(baseDir, pluginDir));
|
||||||
|
pluginInfo = require(path.join(pluginPath, "info"));
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.code === "MODULE_NOT_FOUND") {
|
if (err.code === "MODULE_NOT_FOUND") {
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clusterio master server
|
* Clusterio master server
|
||||||
*
|
*
|
||||||
@@ -9,7 +11,7 @@
|
|||||||
* @module
|
* @module
|
||||||
* @author Danielv123, Hornwitser
|
* @author Danielv123, Hornwitser
|
||||||
* @example
|
* @example
|
||||||
* node master run
|
* npx clusteriomaster run
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Attempt updating
|
// Attempt updating
|
||||||
@@ -38,15 +40,15 @@ let debugEvents = new events.EventEmitter();
|
|||||||
let pluginList = {};
|
let pluginList = {};
|
||||||
|
|
||||||
// homebrew modules
|
// homebrew modules
|
||||||
const generateSSLcert = require("lib/generateSSLcert");
|
const generateSSLcert = require("./src/generate_ssl_cert");
|
||||||
const database = require("lib/database");
|
const database = require("@clusterio/lib/database");
|
||||||
const schema = require("lib/schema");
|
const schema = require("@clusterio/lib/schema");
|
||||||
const link = require("lib/link");
|
const link = require("@clusterio/lib/link");
|
||||||
const errors = require("lib/errors");
|
const errors = require("@clusterio/lib/errors");
|
||||||
const plugin = require("lib/plugin");
|
const plugin = require("@clusterio/lib/plugin");
|
||||||
const prometheus = require("lib/prometheus");
|
const prometheus = require("@clusterio/lib/prometheus");
|
||||||
const config = require("lib/config");
|
const config = require("@clusterio/lib/config");
|
||||||
const users = require("lib/users");
|
const users = require("@clusterio/lib/users");
|
||||||
|
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const compression = require("compression");
|
const compression = require("compression");
|
||||||
@@ -86,9 +88,10 @@ app.use(function(req, res, next){
|
|||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
require("./routes")(app);
|
require("./src/routes")(app);
|
||||||
// Set folder to serve static content from (the website)
|
// Set folder to serve static content from (the website)
|
||||||
app.use(express.static("static"));
|
app.use(express.static(path.join(__dirname, "static")));
|
||||||
|
app.use(express.static("static")); // Used for data export files
|
||||||
|
|
||||||
const endpointHitCounter = new prometheus.Counter(
|
const endpointHitCounter = new prometheus.Counter(
|
||||||
"clusterio_master_http_endpoint_hits_total",
|
"clusterio_master_http_endpoint_hits_total",
|
||||||
@@ -1481,7 +1484,9 @@ async function loadPlugins(pluginInfos) {
|
|||||||
let MasterPlugin = plugin.BaseMasterPlugin;
|
let MasterPlugin = plugin.BaseMasterPlugin;
|
||||||
try {
|
try {
|
||||||
if (pluginInfo.masterEntrypoint) {
|
if (pluginInfo.masterEntrypoint) {
|
||||||
({ MasterPlugin } = require(`./plugins/${pluginInfo.name}/${pluginInfo.masterEntrypoint}`));
|
// XXX Does not work on Windows
|
||||||
|
let pluginPath = path.relative(__dirname, path.join("plugins", pluginInfo.name));
|
||||||
|
({ MasterPlugin } = require(path.join(pluginPath, pluginInfo.masterEntrypoint)));
|
||||||
}
|
}
|
||||||
|
|
||||||
let masterPlugin = new MasterPlugin(
|
let masterPlugin = new MasterPlugin(
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
"name": "@clusterio/master",
|
||||||
|
"description": "Implementation of Clusterio master server",
|
||||||
|
"author": "Hornwitser",
|
||||||
|
"license": "MIT",
|
||||||
|
"version": "2.0.0-alpha0",
|
||||||
|
"main": "master.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
|
"install": "node npm_post_install"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"clusteriomaster": "./master.js"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"factorio"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.16 <11 || >= 11.13"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@clusterio/lib": "=2.0.0-alpha0",
|
||||||
|
"body-parser": "^1.18.2",
|
||||||
|
"compression": "^1.7.2",
|
||||||
|
"cookie-parser": "^1.4.3",
|
||||||
|
"ejs": "^2.5.7",
|
||||||
|
"express": "^4.16.2",
|
||||||
|
"express-fileupload": "1.2.0",
|
||||||
|
"fs-extra": "^8.1.0",
|
||||||
|
"jsonwebtoken": "^8.2.1",
|
||||||
|
"jszip": "^3.2.2",
|
||||||
|
"moment": "^2.22.2",
|
||||||
|
"node-factorio-api": "^0.3.8",
|
||||||
|
"node-forge": "^0.10.0",
|
||||||
|
"request": "^2.83.0",
|
||||||
|
"set-blocking": "^2.0.0",
|
||||||
|
"ws": "^7.2.3",
|
||||||
|
"yargs": "^14.2.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,7 +13,7 @@ module.exports = async function({
|
|||||||
doLogging = false,
|
doLogging = false,
|
||||||
} = {}){
|
} = {}){
|
||||||
function log(t) {
|
function log(t) {
|
||||||
if(doLogging) console.log("lib/generateSSLcert.js | "+t);
|
if(doLogging) console.log("src/generate_ssl_cert.js | "+t);
|
||||||
}
|
}
|
||||||
log("Generating SSL certificate with "+bits+" bits at "+sslCertPath);
|
log("Generating SSL certificate with "+bits+" bits at "+sslCertPath);
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 8.0 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 7.1 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
@@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"name": "@clusterio/slave",
|
||||||
|
"description": "Implementation of Clusterio slave server",
|
||||||
|
"author": "Hornwitser",
|
||||||
|
"license": "MIT",
|
||||||
|
"version": "2.0.0-alpha0",
|
||||||
|
"main": "slave.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"clusterioslave": "./slave.js"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"factorio"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.16 <11 || >= 11.13"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@clusterio/lib": "=2.0.0-alpha0",
|
||||||
|
"fs-extra": "^8.1.0",
|
||||||
|
"phin": "^3.4.1",
|
||||||
|
"pidusage": "^2.0.18",
|
||||||
|
"set-blocking": "^2.0.0",
|
||||||
|
"yargs": "^14.2.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clusterio slave
|
* Clusterio slave
|
||||||
*
|
*
|
||||||
@@ -8,7 +10,7 @@
|
|||||||
* @module
|
* @module
|
||||||
* @author Danielv123, Hornwitser
|
* @author Danielv123, Hornwitser
|
||||||
* @example
|
* @example
|
||||||
* node slave run
|
* npx clusterioslave run
|
||||||
*/
|
*/
|
||||||
"use strict";
|
"use strict";
|
||||||
const fs = require("fs-extra");
|
const fs = require("fs-extra");
|
||||||
@@ -22,14 +24,14 @@ const util = require("util");
|
|||||||
const version = require("./package").version;
|
const version = require("./package").version;
|
||||||
|
|
||||||
// internal libraries
|
// internal libraries
|
||||||
const fileOps = require("lib/fileOps");
|
const fileOps = require("@clusterio/lib/fileOps");
|
||||||
const factorio = require("lib/factorio");
|
const factorio = require("@clusterio/lib/factorio");
|
||||||
const link = require("lib/link");
|
const link = require("@clusterio/lib/link");
|
||||||
const plugin = require("lib/plugin");
|
const plugin = require("@clusterio/lib/plugin");
|
||||||
const errors = require("lib/errors");
|
const errors = require("@clusterio/lib/errors");
|
||||||
const prometheus = require("lib/prometheus");
|
const prometheus = require("@clusterio/lib/prometheus");
|
||||||
const luaTools = require("lib/luaTools");
|
const luaTools = require("@clusterio/lib/luaTools");
|
||||||
const config = require("lib/config");
|
const config = require("@clusterio/lib/config");
|
||||||
|
|
||||||
|
|
||||||
const instanceRconCommandsCounter = new prometheus.Counter(
|
const instanceRconCommandsCounter = new prometheus.Counter(
|
||||||
@@ -198,7 +200,9 @@ class Instance extends link.Link{
|
|||||||
|
|
||||||
async _loadPlugin(pluginInfo, slave) {
|
async _loadPlugin(pluginInfo, slave) {
|
||||||
let pluginLoadStarted = Date.now();
|
let pluginLoadStarted = Date.now();
|
||||||
let { InstancePlugin } = require(`./plugins/${pluginInfo.name}/${pluginInfo.instanceEntrypoint}`);
|
// XXX Does not work on Windows
|
||||||
|
let pluginPath = path.relative(__dirname, path.join("plugins", pluginInfo.name));
|
||||||
|
let { InstancePlugin } = require(path.join(pluginPath, pluginInfo.instanceEntrypoint));
|
||||||
let instancePlugin = new InstancePlugin(pluginInfo, this, slave);
|
let instancePlugin = new InstancePlugin(pluginInfo, this, slave);
|
||||||
this.plugins.set(pluginInfo.name, instancePlugin);
|
this.plugins.set(pluginInfo.name, instancePlugin);
|
||||||
await instancePlugin.init();
|
await instancePlugin.init();
|
||||||
@@ -1423,9 +1427,9 @@ async function startSlave() {
|
|||||||
console.error("ERROR invalid config!");
|
console.error("ERROR invalid config!");
|
||||||
console.error(
|
console.error(
|
||||||
"Master server requires an access token for socket operations. As clusterio\n"+
|
"Master server requires an access token for socket operations. As clusterio\n"+
|
||||||
"slaves depends upon this, please set your token using the command node slave\n"+
|
"slaves depends upon this, please set your token using the command npx\n"+
|
||||||
"config set slave.master_token <token>. You can generate an auth token using\n"+
|
"clusterioslave config set slave.master_token <token>. You can generate an\n"+
|
||||||
"using node clusterctl generate-slave-token."
|
"auth token using npx clusterctl generate-slave-token."
|
||||||
);
|
);
|
||||||
process.exitCode = 1;
|
process.exitCode = 1;
|
||||||
return;
|
return;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
const plugin = require("lib/plugin");
|
const plugin = require("@clusterio/lib/plugin");
|
||||||
const info = require("./info");
|
const info = require("./info");
|
||||||
const command = require("lib/command");
|
const command = require("@clusterio/lib/command");
|
||||||
|
|
||||||
|
|
||||||
const globalChatCommands = new command.CommandTree({ name: "global-chat", description: "Global Chat plugin commands" });
|
const globalChatCommands = new command.CommandTree({ name: "global-chat", description: "Global Chat plugin commands" });
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
let link = require("lib/link");
|
let link = require("@clusterio/lib/link");
|
||||||
let plugin = require("lib/plugin");
|
let plugin = require("@clusterio/lib/plugin");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: "global_chat",
|
name: "global_chat",
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
* @module
|
* @module
|
||||||
*/
|
*/
|
||||||
"use strict";
|
"use strict";
|
||||||
const plugin = require("lib/plugin");
|
const plugin = require("@clusterio/lib/plugin");
|
||||||
const luaTools = require("lib/luaTools");
|
const luaTools = require("@clusterio/lib/luaTools");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
const link = require("lib/link");
|
const link = require("@clusterio/lib/link");
|
||||||
|
|
||||||
|
|
||||||
// schema used for syncing technologies to and from the master
|
// schema used for syncing technologies to and from the master
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
const needle = require("needle");
|
const plugin = require("@clusterio/lib/plugin");
|
||||||
|
const luaTools = require("@clusterio/lib/luaTools");
|
||||||
const plugin = require("lib/plugin");
|
|
||||||
const luaTools = require("lib/luaTools");
|
|
||||||
|
|
||||||
|
|
||||||
function unexpectedError(err) {
|
function unexpectedError(err) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
const fs = require("fs-extra");
|
const fs = require("fs-extra");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
const plugin = require("lib/plugin");
|
const plugin = require("@clusterio/lib/plugin");
|
||||||
|
|
||||||
|
|
||||||
class MasterPlugin extends plugin.BaseMasterPlugin {
|
class MasterPlugin extends plugin.BaseMasterPlugin {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
let link = require("lib/link");
|
let link = require("@clusterio/lib/link");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: "statistics_exporter",
|
name: "statistics_exporter",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
const plugin = require("lib/plugin");
|
const plugin = require("@clusterio/lib/plugin");
|
||||||
const { Gauge } = require("lib/prometheus");
|
const { Gauge } = require("@clusterio/lib/prometheus");
|
||||||
|
|
||||||
|
|
||||||
const instancePlayerCount = new Gauge(
|
const instancePlayerCount = new Gauge(
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
const doleNN = require("./dole_nn_base");
|
const doleNN = require("./dole_nn_base");
|
||||||
|
|
||||||
const prometheus = require("lib/prometheus");
|
const prometheus = require("@clusterio/lib/prometheus");
|
||||||
|
|
||||||
|
|
||||||
const prometheusNNDoleGauge = new prometheus.Gauge(
|
const prometheusNNDoleGauge = new prometheus.Gauge(
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
const link = require("lib/link");
|
const link = require("@clusterio/lib/link");
|
||||||
const config = require("lib/config");
|
const config = require("@clusterio/lib/config");
|
||||||
|
|
||||||
class MasterConfigGroup extends config.PluginConfigGroup {}
|
class MasterConfigGroup extends config.PluginConfigGroup {}
|
||||||
MasterConfigGroup.groupName = "subspace_storage";
|
MasterConfigGroup.groupName = "subspace_storage";
|
||||||
|
|||||||