You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

80 lines
1.9 KiB

  1. require('./globals');
  2. const server = require('./server/index');
  3. const components = require('./components/components');
  4. const mods = require('./misc/mods');
  5. const animations = require('./config/animations');
  6. const skins = require('./config/skins');
  7. const factions = require('./config/factions');
  8. const classes = require('./config/spirits');
  9. const spellsConfig = require('./config/spellsConfig');
  10. const spells = require('./config/spells');
  11. const itemTypes = require('./items/config/types');
  12. const recipes = require('./config/recipes/recipes');
  13. const mapManager = require('./world/mapManager');
  14. const fixes = require('./fixes/fixes');
  15. const profanities = require('./misc/profanities');
  16. const routerConfig = require('./security/routerConfig');
  17. const { spawnMapThreads } = require('./world/threadManager');
  18. let startup = {
  19. init: function () {
  20. io.init(this.onDbReady.bind(this));
  21. },
  22. onDbReady: async function () {
  23. await fixes.fixDb();
  24. process.on('unhandledRejection', this.onError.bind(this));
  25. process.on('uncaughtException', this.onError.bind(this));
  26. await mods.init();
  27. this.onModsLoaded();
  28. },
  29. onModsLoaded: function () {
  30. animations.init();
  31. routerConfig.init();
  32. classes.init();
  33. spellsConfig.init();
  34. spells.init();
  35. recipes.init();
  36. itemTypes.init();
  37. profanities.init();
  38. mapManager.init();
  39. components.init(this.onComponentsReady.bind(this));
  40. },
  41. onComponentsReady: async function () {
  42. skins.init();
  43. factions.init();
  44. await clientConfig.init();
  45. await server.init();
  46. await leaderboard.init();
  47. await spawnMapThreads();
  48. },
  49. onError: async function (e) {
  50. if (e.toString().indexOf('ERR_IPC_CHANNEL_CLOSED') > -1)
  51. return;
  52. _.log('Error Logged: ' + e.toString());
  53. _.log(e.stack);
  54. await io.setAsync({
  55. key: new Date(),
  56. table: 'error',
  57. value: e.toString() + ' | ' + e.stack.toString()
  58. });
  59. process.exit();
  60. }
  61. };
  62. startup.init();