Rename client.js to slave.js

Rename the client.js script to slave.js, and changed places where it's
refered to as client into slave.
This commit is contained in:
Hornwitser committed 2020-04-03 20:51:28 +02:00
1 parent ae86781b0d
commit 028f00e58a
7 files changed
+37 -37

No files matched your search

+1
View File
@@ -81,6 +81,7 @@ Version 2.0.0
- Removed UPSdisplay plugin. UPS statistics is exported by the statistics
exporter plugin.
- Master server now defaults to hosting on https on port 8443.
- Renamed client to slave.
### Breaking Changes
+7 -7
View File
@@ -128,7 +128,7 @@ Clusterio has *very* limited support for using docker.
sudo docker run --name master -e MODE=master -p 1234:8080 -d -it --restart=unless-stopped danielvestol/clusterio
sudo docker run --name slave -e MODE=client -e INSTANCE=world1 -v /srv/clusterio/instances:/factorioClusterio/instances -p 1235:34167 -it --restart=unless-stopped danielvestol/clusterio
sudo docker run --name slave -e MODE=slave -e INSTANCE=world1 -v /srv/clusterio/instances:/factorioClusterio/instances -p 1235:34167 -it --restart=unless-stopped danielvestol/clusterio
The -v flag is used to specify the instance directory. Your instances (save files etc) will be stored there.
-->
@@ -142,7 +142,7 @@ Clusterio is built up of multiple parts. Here is a quick guide:
Master = master.js
Server host (Slave) = client.js + factorio server
Server host (Slave) = slave.js + factorio server
Game Client = The people connecting to the server
@@ -213,20 +213,20 @@ up.
To set up the configuration for a new local slave run the following.
node client config set slave.name "Local"
node client config set slave.master_token "<token>"
node slave config set slave.name "Local"
node slave config set slave.master_token "<token>"
This will write a new `config-slave.json` file in the current directory
(you can change the location with the `--config` option) with the name
and token provided. If you are connecting to a remote master server you
will also need to set the `slave.master_url` option to that url.
You can list the config of a slave with the `node client config list`
command. Use `node client config --help` for more information.
You can list the config of a slave with the `node slave config list`
command. Use `node slave config --help` for more information.
Once the config is set up run the slave with
node client start
node slave run
### Instances
+1 -1
View File
@@ -36,7 +36,7 @@ function formatBytes(size, decimals) {
/**
Lists mods for an instance as a table. Warning, handles printing internally.
@param {Instance} instance - Instance object, see client.js
@param {Instance} instance - Instance object, see slave.js
@example
var modManager = require("modManager");
-1
View File
@@ -10,7 +10,6 @@
"cover": "nyc npm test",
"fast-cover": "FAST_TEST=y nyc npm test",
"ci-cover": "nyc --reporter=lcovonly npm run-script test",
"start": "echo Run node client start [instance] to start slaves && node master",
"install": "node lib/npmPostinstall",
"bundle-dependencies": "bundle-dependencies"
},
+11 -11
View File
@@ -761,13 +761,13 @@ async function symlinkMods(instance, sharedMods, logger) {
}
}
async function startClient() {
async function startSlave() {
// add better stack traces on promise rejection
process.on('unhandledRejection', r => console.log(r));
// argument parsing
const args = yargs
.scriptName("client")
.scriptName("slave")
.usage("$0 <command> [options]")
.option('config', {
nargs: 1,
@@ -776,7 +776,7 @@ async function startClient() {
type: 'string',
})
.command("config", "Manage Slave config", config.configCommand)
.command('start', "Start slave")
.command("run", "Run slave")
.demandCommand(1, "You need to specify a command to run")
.strict()
.argv
@@ -808,7 +808,7 @@ async function startClient() {
return;
}
// If we get here the command was start
// If we get here the command was run
await fs.ensureDir(slaveConfig.get("slave.instances_directory"));
await fs.ensureDir("sharedMods");
@@ -816,14 +816,14 @@ async function startClient() {
// Set the process title, shows up as the title of the CMD window on windows
// and as the process name in ps/top on linux.
process.title = "clusterioClient";
process.title = "clusterioSlave";
// make sure we have the master access token
if (slaveConfig.get("slave.master_token") === "enter token here") {
console.error("ERROR invalid config!");
console.error(
"Master server now needs an access token for write operations. As clusterio\n"+
"slaves depends upon this, please set your token using the command node client\n"+
"slaves depends upon this, please set your token using the command node slave\n"+
"config set slave.master_token <token>. You can retrieve your auth token from\n"+
"the master in secret-api-token.txt after running it once."
);
@@ -916,12 +916,12 @@ I version of clusterio. Expect things to break. I
+==========================================================+
`
);
startClient().catch(err => {
startSlave().catch(err => {
console.error(`
+---------------------------------------------------------------+
| Unexpected error occured while starting client, please report |
| it to https://github.com/clusterio/factorioClusterio/issues |
+---------------------------------------------------------------+`
+--------------------------------------------------------------+
| Unexpected error occured while starting slave, please report |
| it to https://github.com/clusterio/factorioClusterio/issues |
+--------------------------------------------------------------+`
);
console.error(err);
+6 -6
View File
@@ -79,17 +79,17 @@ before(async function() {
await exec(`node master --config ${masterConfigPath} config set master.https_port 4443`);
await exec(`node master --config ${masterConfigPath} config set master.heartbeat_interval 0.25`);
await exec(`node client --config ${slaveConfigPath} config set slave.id 4`);
await exec(`node client --config ${slaveConfigPath} config set slave.name slave`);
await exec(`node client --config ${slaveConfigPath} config set slave.instances_directory ${instancesDir}`);
await exec(`node client --config ${slaveConfigPath} config set slave.master_url "${url}"`);
await exec(`node client --config ${slaveConfigPath} config set slave.master_token "${token}"`);
await exec(`node slave --config ${slaveConfigPath} config set slave.id 4`);
await exec(`node slave --config ${slaveConfigPath} config set slave.name slave`);
await exec(`node slave --config ${slaveConfigPath} config set slave.instances_directory ${instancesDir}`);
await exec(`node slave --config ${slaveConfigPath} config set slave.master_url "${url}"`);
await exec(`node slave --config ${slaveConfigPath} config set slave.master_token "${token}"`);
await exec(`node clusterctl --config ${controlConfigPath} control-config set control.master_url "https://localhost:4443/"`);
await exec(`node clusterctl --config ${controlConfigPath} control-config set control.master_token "${token}"`);
masterProcess = await spawn("master:", `node master --config ${masterConfigPath} run`, "All plugins loaded");
slaveProcess = await spawn("slave:", `node client --config ${slaveConfigPath} start`, "SOCKET | received ready from master");
slaveProcess = await spawn("slave:", `node slave --config ${slaveConfigPath} run`, "SOCKET | received ready from master");
});
after(async function() {
+11 -11
View File
@@ -4,9 +4,9 @@ const fs = require('fs-extra');
const link = require("lib/link");
const config = require("lib/config");
const client = require("../client");
const slave = require("../slave");
describe("Client testing", function() {
describe("Slave testing", function() {
before(function() {
config.InstanceConfig.finalize();
});
@@ -17,7 +17,7 @@ describe("Client testing", function() {
let instanceConfig = new config.InstanceConfig();
await instanceConfig.init();
instanceConfig.set("instance.name", "foo");
instance = new client._Instance(new link.VirtualConnector(), "dir", "factorioDir", instanceConfig);
instance = new slave._Instance(new link.VirtualConnector(), "dir", "factorioDir", instanceConfig);
});
describe(".name", function() {
@@ -38,11 +38,11 @@ describe("Client testing", function() {
describe("checkFilename()", function() {
it("should allow a basic name", function() {
client._checkFilename("file");
slave._checkFilename("file");
});
function check(item, msg) {
assert.throws(() => client._checkFilename(item), new Error(msg));
assert.throws(() => slave._checkFilename(item), new Error(msg));
}
it("should throw on non-string", function() {
@@ -108,14 +108,14 @@ describe("Client testing", function() {
let instanceConfig = new config.InstanceConfig();
await instanceConfig.init();
instanceConfig.set("instance.name", "test");
instance = new client._Instance(
instance = new slave._Instance(
new link.VirtualConnector(), path.join(testDir, "instance"), "factorioDir", instanceConfig
);
await fs.outputFile(instance.path("mods", "mod_i.zip"), "i");
});
it("should link mods and data files", async function() {
await client._symlinkMods(instance, path.join(testDir, "shared"), discardingLogger);
await slave._symlinkMods(instance, path.join(testDir, "shared"), discardingLogger);
assert.equal(await fs.readFile(instance.path("mods", "mod_a.zip"), "utf-8"), "a");
assert.equal(await fs.readFile(instance.path("mods", "mod_b.zip"), "utf-8"), "b");
@@ -125,14 +125,14 @@ describe("Client testing", function() {
it("should ignore directories", async function() {
await fs.ensureDir(path.join(testDir, "shared", "dir"));
await client._symlinkMods(instance, path.join(testDir, "shared"), discardingLogger);
await slave._symlinkMods(instance, path.join(testDir, "shared"), discardingLogger);
assert(!await fs.exists(instance.path("mods", "dir"), "utf-8"), "dir was unxpectedly linked");
});
it("should ignore files", async function() {
await fs.outputFile(path.join(testDir, "shared", "file"), "f");
await client._symlinkMods(instance, path.join(testDir, "shared"), discardingLogger);
await slave._symlinkMods(instance, path.join(testDir, "shared"), discardingLogger);
assert(!await fs.exists(instance.path("mods", "file"), "utf-8"), "dir was unxpectedly linked");
});
@@ -144,7 +144,7 @@ describe("Client testing", function() {
}
await fs.unlink(path.join(testDir, "shared", "mod_a.zip"));
await client._symlinkMods(instance, path.join(testDir, "shared"), discardingLogger);
await slave._symlinkMods(instance, path.join(testDir, "shared"), discardingLogger);
await assert.rejects(fs.lstat(instance.path("mods", "mod_a.zip")), { code: "ENOENT" });
assert.equal(await fs.readFile(instance.path("mods", "mod_b.zip"), "utf-8"), "b");
@@ -157,7 +157,7 @@ describe("Client testing", function() {
it("should discover test instance", async function() {
let logger = { log: () => {}, error: () => {} };
let instancePath = path.join("test", "file", "instances");
let instanceInfos = await client._discoverInstances(instancePath, logger);
let instanceInfos = await slave._discoverInstances(instancePath, logger);
let referenceConfig = new config.InstanceConfig();
await referenceConfig.init();