app.js 1014 B

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