app.js 965 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * 全局定义
  3. * @param app
  4. */
  5. 'use strict';
  6. class AppBootHook {
  7. constructor(app) {
  8. this.app = app;
  9. global.OS_PLATFORM = process.platform;
  10. global.IS_WIN = /^win/.test(process.platform);
  11. }
  12. configWillLoad() {
  13. // Ready to call configDidLoad,
  14. // Config, plugin files are referred,
  15. // this is the last chance to modify the config.
  16. }
  17. configDidLoad() {
  18. // Config, plugin files have been loaded.
  19. }
  20. async didLoad() {
  21. // All files have loaded, start plugin here.
  22. }
  23. async willReady() {
  24. // All plugins have started, can do some thing before app ready
  25. }
  26. async didReady() {
  27. // Worker is ready, can do some things
  28. // don't need to block the app boot.
  29. }
  30. async serverDidReady() {
  31. // Server is listening.
  32. // const storageFile = './storage';
  33. // utils.chmodPath(storageFile, '777');
  34. }
  35. async beforeClose() {
  36. // Do some thing before app close.
  37. }
  38. }
  39. module.exports = AppBootHook;