Преглед изворни кода

Stop the server if an error occurs

Shun Miyazawa пре 3 година
родитељ
комит
0b49c8a73e

+ 1 - 0
packages/app/src/server/crowi/index.js

@@ -704,6 +704,7 @@ Crowi.prototype.setupActivityService = async function() {
   const ActivityService = require('../service/activity');
   if (this.activityService == null) {
     this.activityService = new ActivityService(this);
+    await this.activityService.createTtlIndex();
   }
 };
 

+ 2 - 2
packages/app/src/server/service/activity.ts

@@ -25,7 +25,6 @@ class ActivityService {
 
     this.updateByParameters = this.updateByParameters.bind(this);
 
-    this.createTtlIndex();
     this.initActivityEventListeners();
   }
 
@@ -46,12 +45,13 @@ class ActivityService {
     });
   }
 
-  private createTtlIndex = async function() {
+  createTtlIndex = async function() {
     const configManager = this.crowi.configManager;
     const activityExpirationSeconds = configManager != null ? configManager.getConfig('crowi', 'app:activityExpirationSeconds') : 7776000;
     const collection = mongoose.connection.collection('activities');
 
     try {
+      throw Error('えらー');
       const indexes = await collection.indexes();
       const ttlIndex = indexes.find(i => i.name === 'createdAt_1');
       const shoudCreateIndex = ttlIndex == null;