mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-05-06 05:27:54 -05:00
Load tools' data for main process from plugin requiring it
This allows servers which remove `info.js` plugin to cut down RAM consumption.
This commit is contained in:
parent
2c6ca3ef1e
commit
2a1f930632
15
app.js
15
app.js
|
|
@ -307,12 +307,18 @@ global.toId = function (text) {
|
|||
return ('' + text).toLowerCase().replace(/[^a-z0-9]+/g, '');
|
||||
};
|
||||
|
||||
global.Tools = require('./tools.js').includeFormats();
|
||||
|
||||
global.LoginServer = require('./loginserver.js');
|
||||
|
||||
global.Users = require('./users.js');
|
||||
|
||||
global.Rooms = require('./rooms.js');
|
||||
|
||||
// Generate and cache the format list.
|
||||
Rooms.global.formatListText = Rooms.global.getFormatListText();
|
||||
|
||||
|
||||
delete process.send; // in case we're a child process
|
||||
global.Verifier = require('./verifier.js');
|
||||
|
||||
|
|
@ -359,15 +365,6 @@ global.Sockets = require('./sockets.js');
|
|||
* Set up our last global
|
||||
*********************************************************/
|
||||
|
||||
// This slow operation is done *after* we start listening for connections
|
||||
// to the server. Anybody who connects while this require() is running will
|
||||
// have to wait a couple seconds before they are able to join the server, but
|
||||
// at least they probably won't receive a connection error message.
|
||||
global.Tools = require('./tools.js').includeData();
|
||||
|
||||
// After loading tools, generate and cache the format list.
|
||||
Rooms.global.formatListText = Rooms.global.getFormatListText();
|
||||
|
||||
global.TeamValidator = require('./team-validator.js');
|
||||
|
||||
// load ipbans at our leisure
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
const RESULTS_MAX_LENGTH = 10;
|
||||
|
||||
var commands = exports.commands = {
|
||||
var commands = {
|
||||
|
||||
ip: 'whois',
|
||||
rooms: 'whois',
|
||||
|
|
@ -2360,3 +2360,14 @@ var commands = exports.commands = {
|
|||
},
|
||||
htmlboxhelp: ["/htmlbox [message] - Displays a message, parsing HTML code contained. Requires: ~ # with global authority"]
|
||||
};
|
||||
|
||||
process.nextTick(function () {
|
||||
// This slow operation is done *after* we start listening for connections
|
||||
// to the server. Anybody who connects while data is loading will
|
||||
// have to wait a couple seconds before they are able to join the server, but
|
||||
// at least they probably won't receive a connection error message.
|
||||
|
||||
Tools.includeData();
|
||||
exports.commands = commands;
|
||||
Object.merge(CommandParser.commands, commands);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1456,10 +1456,11 @@ var commands = exports.commands = {
|
|||
return this.sendReply("Battles have been hotpatched. Any battles started after now will use the new code; however, in-progress battles will continue to use the old code.");
|
||||
} else if (target === 'formats') {
|
||||
try {
|
||||
var toolsLoaded = !!Tools.isLoaded;
|
||||
// uncache the tools.js dependency tree
|
||||
CommandParser.uncacheTree('./tools.js');
|
||||
// reload tools.js
|
||||
global.Tools = require('./tools.js').includeData(); // note: this will lock up the server for a few seconds
|
||||
global.Tools = require('./tools.js')[toolsLoaded ? 'includeData' : 'includeFormats'](); // note: this will lock up the server for a few seconds
|
||||
// rebuild the formats list
|
||||
Rooms.global.formatListText = Rooms.global.getFormatListText();
|
||||
// respawn validator processes
|
||||
|
|
@ -1475,10 +1476,11 @@ var commands = exports.commands = {
|
|||
}
|
||||
} else if (target === 'learnsets') {
|
||||
try {
|
||||
var toolsLoaded = !!Tools.isLoaded;
|
||||
// uncache the tools.js dependency tree
|
||||
CommandParser.uncacheTree('./tools.js');
|
||||
// reload tools.js
|
||||
global.Tools = require('./tools.js').includeData(); // note: this will lock up the server for a few seconds
|
||||
global.Tools = require('./tools.js')[toolsLoaded ? 'includeData' : 'includeFormats'](); // note: this will lock up the server for a few seconds
|
||||
|
||||
return this.sendReply("Learnsets have been hotpatched.");
|
||||
} catch (e) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user