-
Notifications
You must be signed in to change notification settings - Fork 16
/
config.ts
268 lines (241 loc) · 5.63 KB
/
config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
import crypto from 'crypto';
import os from 'os';
// When making changes to the schema, remember to generate a new typescript json schema with the below command
// npx typescript-json-schema tsconfig.json Schema --include ./src/config/config.ts --defaultProps --required -o ./src/config/config.schema.json
export type Schema = {
/**
* List of mods to load
*/
mods?: string[];
/**
* Backend server settings
*/
backend?: {
/**
* Whether to allow read-only access to the API without logging in.
* @default true
*/
allowGuestAccess?: boolean;
/**
* Whether to allow users sign up without steam with only their email address.
* Note: there is currently no confirmation mail send to the user to verify the address.
* @default false
*/
allowEmailRegistration?: boolean;
/**
* Network interface to bind server to. Format is: "host" or "host:port". Host can be * to bind
* to all interfaces: "*:port". Port is 21025, if not specified.
* @default *
*/
bind?: string;
/**
* Secret used for session authentication. If not specified a new secret will be generated each
* restart.
*/
secret?: string;
/**
* Minimum time between socket updates, in milliseconds. Setting this lower may cause
* performance issues in the client.
* @default 125
*/
socketThrottle?: number;
/**
* Steam Web API key used to authenticate users. You can get a key here:
* http://steamcommunity.com/dev/apikey
*/
steamApiKey?: string;
};
/**
* Game settings
*/
game?: {
/**
* Amount of time in hours before a user is allowed to respawn, counted from the time of their
* initial spawn placement.
* @default 0
*/
respawnTimeout?: number;
/**
* Minimum length of a game tick in milliseconds.
* @default 250
*/
tickSpeed?: number;
};
/**
* Launcher settings
*/
launcher?: {
/**
* Set true to run all services in a single nodejs isolate. This does *not* affect the runner's
* isolates.
* @default false
*/
singleThreaded?: boolean;
};
/**
* Processor settings
*/
processor?: {
/**
* Total number of processor tasks to run at a time. The default is the number of CPU cores
* (including hyper-threaded) + 1
*/
concurrency?: number;
/**
* Timeout in milliseconds before the processors give up on waiting for intents from the Runner
* service and continue processing all outstanding rooms.
* @default 5000
*/
intentAbandonTimeout?: number;
};
/**
* Runner settings
*/
runner?: {
cpu?: {
/**
* CPU bucket size per user
* @default: 10000
*/
bucket?: number;
/**
* Memory limit, in megabytes. The actual memory limit as reported by the isolate will be
* higher, since it accounts for shared terrain data.
*
* This option does nothing when `unsafeSandbox` is true.
* @default 256
*/
memoryLimit?: number;
/**
* Maximum amount of time in milliseconds that a user's runtime may run for.
* @default: 500
*/
tickLimit?: number;
};
/**
* Total number of run tasks to run at a time. The default is the number of CPU cores (including
* hyper-threaded) + 1
*/
concurrency?: number;
/**
* How long an idle runner will wait before migrating a player sandbox into that runner, causing
* a hard reset for the player.
* @default 50
*/
migrationTimeout?: number;
/**
* Setting this to true will run user code using the nodejs `vm` module instead
* of `isolated-vm`. Do not enable this on public servers!
* @default false
*/
unsafeSandbox?: boolean;
};
/**
* Where to save descriptions of the binary format used to write game data.
* @default ./screeps/archive
*/
schemaArchive?: string | undefined;
/**
* Configuration for global database storage
*/
database?: {
/**
* Persistent storage provider URI
* @default ./screeps/db
*/
data: string;
/**
* Pubsub storage provider URI
* @default local://db
*/
pubsub: string;
/**
* How often (in wall time minutes) to save the main database
* @default 120
*/
saveInterval?: number;
};
/**
* Configuration for shard-specific storage
* @default `[ {
* name: 'shard0',
* data: './screeps/shard0',
* pubsub: 'local://shard0',
* scratch: 'local://shard0',
* } ]`
*/
shards?: {
/**
* Name of this shard
*/
name: string;
/**
* Persistent storage provider URI
*/
data: string;
/**
* Pubsub storage provider URI
*/
pubsub: string;
/**
* Temporary storage provider URI
*/
scratch: string;
}[];
};
/**
* These defaults will be merged into `xxscreepts/config` at runtime
*/
export const defaults = {
backend: {
allowGuestAccess: true as boolean,
bind: '*',
socketThrottle: 125,
},
game: {
respawnTimeout: 0,
},
processor: {
concurrency: os.cpus().length + 1,
intentAbandonTimeout: 5000,
},
runner: {
concurrency: os.cpus().length + 1,
cpu: {
bucket: 10000,
memoryLimit: 256,
tickLimit: 500,
},
migrationTimeout: 50,
},
schemaArchive: './screeps/archive',
database: {
data: './screeps/db',
pubsub: 'local://db',
saveInterval: 2,
},
shards: [ {
name: 'shard0',
data: './screeps/shard0',
pubsub: 'local://shard0',
scratch: 'local://shard0',
} ],
};
/**
* These defaults will be written to `.screepsrc.yaml` on import, as a guide for the user. They will
* also be merged into the `config` defaults.
*/
export const configDefaults = {
mods: [
'xxscreeps/mods/classic',
'xxscreeps/mods/backend/cookie',
'xxscreeps/mods/backend/password',
'xxscreeps/mods/backend/steam',
],
backend: {
secret: crypto.randomBytes(16).toString('hex'),
},
game: {
tickSpeed: 250,
},
};