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.
 
 
 

83 lines
1.9 KiB

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