@tiledesk/tiledesk-server 2.9.14 → 2.9.15

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,9 @@
5
5
  🚀 IN PRODUCTION 🚀
6
6
  (https://www.npmjs.com/package/@tiledesk/tiledesk-server/v/2.3.77)
7
7
 
8
+ # 2.9.15
9
+ - Updated jobs-worker-queue-manager
10
+
8
11
  # 2.9.14
9
12
  - Added replace option in chatbot import json
10
13
  - Added field project_user, fullname, email and assigned requests to what /users/availables returns
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-server",
3
3
  "description": "The Tiledesk server module",
4
- "version": "2.9.14",
4
+ "version": "2.9.15",
5
5
  "scripts": {
6
6
  "start": "node ./bin/www",
7
7
  "pretest": "mongodb-runner start",
package/routes/kb.js CHANGED
@@ -28,8 +28,12 @@ let jobManager = new JobManager(AMQP_MANAGER_URL, {
28
28
  exchange: JOB_TOPIC_EXCHANGE
29
29
  })
30
30
 
31
- jobManager.connectAndStartPublisher(() => {
32
- winston.info("ConnectPublisher done");
31
+ jobManager.connectAndStartPublisher((status, error) => {
32
+ if (error) {
33
+ winston.error("connectAndStartPublisher error: ", error);
34
+ } else {
35
+ winston.info("KbRoute - ConnectPublisher done with status: ", status);
36
+ }
33
37
  })
34
38
 
35
39
  let default_preview_settings = {
@@ -21,7 +21,15 @@ class JobManager {
21
21
  var that = this;
22
22
  if (this.info) {console.log("[JobWorker] JobManager publisher started");}
23
23
 
24
- this.queueManager.connect(function() {
24
+ this.queueManager.connect(function(status, err) {
25
+
26
+ if (err) {
27
+ console.log("[JobWorker] - connectAndStartPublisher - connection error: ", err);
28
+ if (callback) {
29
+ callback(null, err)
30
+ return;
31
+ }
32
+ }
25
33
  if (that.debug) {console.log("[JobWorker] Queue started");}
26
34
  that.queuePublisherConnected = true;
27
35
 
@@ -41,7 +49,8 @@ class JobManager {
41
49
  }
42
50
 
43
51
  if (callback) {
44
- callback();
52
+ callback(status, null);
53
+ return;
45
54
  }
46
55
  });
47
56
  });
@@ -46,29 +46,37 @@ connect(callback) {
46
46
  amqp.connect(this.url, function(err, conn) {
47
47
  if (err) {
48
48
  // if (this.debug) {console.log("[AMQP]", err.message);
49
- if (that.debug) {console.log("[JobWorker] AMQP", err);}
49
+ // if (that.debug) {console.log("[JobWorker] AMQP", err);}
50
+ console.error("[JobWorker] AMQP", err);
51
+ console.log("[JobWorker] Try to reconnect");
50
52
 
51
53
  return setTimeout(function() {
52
54
  that.connect()
53
55
  }, 1000);
54
56
  }
55
57
  conn.on("error", function(err) {
58
+ console.error("[JobWorker] err.message", err.message);
56
59
  if (err.message !== "Connection closing") {
57
- if (that.debug) {console.log("[JobWorker] AMQP conn error", err);}
60
+ //if (that.debug) {console.log("[JobWorker] AMQP conn error", err);}
61
+ console.log("[JobWorker] AMQP conn error", err)
62
+ if (callback) {
63
+ callback(null, err)
64
+ }
58
65
  }
59
66
  });
60
67
  conn.on("close", function() {
61
- if (that.debug) {console.log("[JobWorker] AMQP reconnecting");}
68
+ // if (that.debug) {console.log("[JobWorker] AMQP reconnecting");}
69
+ console.log("[JobWorker] AMQP reconnecting")
62
70
  return setTimeout(that.connect, 1000);
63
71
  });
64
72
 
65
- if (that.debug) {console.log("[JobWorker] AMQP connected");}
73
+ console.log("[JobWorker] AMQP connected")
66
74
  that.amqpConn = conn;
67
75
 
68
76
  // that.whenConnected(callback);
69
77
 
70
78
  if (callback) {
71
- callback();
79
+ callback('Connected', null);
72
80
  }
73
81
  // return resolve();
74
82
  // });
@@ -96,10 +104,12 @@ startPublisher(callback) {
96
104
  that.amqpConn.createConfirmChannel(function(err, ch) {
97
105
  if (that.closeOnErr(err)) return;
98
106
  ch.on("error", function(err) {
99
- if (that.debug) {console.log("[JobWorker] AMQP channel error", err);}
107
+ // if (that.debug) {console.log("[JobWorker] - startPublisher AMQP channel error", err);}
108
+ console.log("[JobWorker] - startPublisher AMQP channel error", err);
100
109
  });
101
110
  ch.on("close", function() {
102
- if (that.debug) {console.log("[JobWorker] AMQP channel closed");}
111
+ // if (that.debug) {console.log("[JobWorker] AMQP channel closed");}
112
+ console.log("[JobWorker] - startPublisher AMQP channel closed")
103
113
  });
104
114
 
105
115
  // if (this.debug) {console.log("[AMQP] pubChannel");