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.
 
 
 

74 lines
1.7 KiB

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