bdy 1.22.4-dev → 1.22.5-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.22.4-dev",
4
+ "version": "1.22.5-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -94,7 +94,12 @@ WantedBy=multi-user.target`;
94
94
  try {
95
95
  const json = this.loadSystemConfig();
96
96
  logger_1.default.info(texts_1.LOG_AGENT_STOPPING_SYSTEM);
97
- await this.stop();
97
+ try {
98
+ await this.stop();
99
+ }
100
+ catch {
101
+ // do nothing
102
+ }
98
103
  await this.saveFile(this.getServicePath(), this.getServiceConfig(json.id, json.host, json.token, json.port, user, json.debug));
99
104
  logger_1.default.info(texts_1.LOG_AGENT_STARTING_SYSTEM);
100
105
  await this.start();
@@ -107,7 +112,12 @@ WantedBy=multi-user.target`;
107
112
  async update() {
108
113
  try {
109
114
  logger_1.default.info(texts_1.LOG_AGENT_STOPPING_SYSTEM);
110
- await this.stop();
115
+ try {
116
+ await this.stop();
117
+ }
118
+ catch {
119
+ // do nothing
120
+ }
111
121
  logger_1.default.info(texts_1.LOG_AGENT_SYSTEM_DIR);
112
122
  await this.ensureSystemConfigDir();
113
123
  logger_1.default.info(texts_1.LOG_AGENT_DOWNLOADING_ARCHIVE);
@@ -49,7 +49,24 @@ class AgentManagerClass {
49
49
  this.system = new system_1.default();
50
50
  }
51
51
  }
52
- start(id, host, token, port) {
52
+ start(id, host, token, port, onProcessExit = () => { }) {
53
+ const onExit = () => {
54
+ onProcessExit();
55
+ if (this.ws) {
56
+ this.ws.clients.forEach((client) => client.terminate());
57
+ this.ws.close();
58
+ }
59
+ if (this.server) {
60
+ this.server.closeAllConnections();
61
+ this.server.close(() => {
62
+ process.exit();
63
+ });
64
+ }
65
+ setTimeout(() => process.exit(0), 1000);
66
+ };
67
+ process.on('SIGINT', onExit);
68
+ process.on('SIGTERM', onExit);
69
+ process.on('SIGQUIT', onExit);
53
70
  this.load(id, host, token, port).then();
54
71
  }
55
72
  async tryFetch() {
@@ -256,7 +273,7 @@ class AgentManagerClass {
256
273
  enabled: !this.agent?.disabled,
257
274
  target: !!this.agent?.target,
258
275
  tunneling: !!this.agent?.tunneling,
259
- proxy: !!this.agent?.proxy
276
+ proxy: !!this.agent?.proxy,
260
277
  });
261
278
  }
262
279
  processBody(req) {
@@ -111,7 +111,12 @@ class AgentOsx extends system_1.default {
111
111
  try {
112
112
  const json = this.loadSystemConfig();
113
113
  logger_1.default.info(texts_1.LOG_AGENT_STOPPING_SYSTEM);
114
- await this.stop();
114
+ try {
115
+ await this.stop();
116
+ }
117
+ catch {
118
+ // do nothing
119
+ }
115
120
  await this.saveFile(this.getServicePath(), this.getServiceConfig(json.id, json.host, json.token, json.port, user, json.debug));
116
121
  logger_1.default.info(texts_1.LOG_AGENT_STARTING_SYSTEM);
117
122
  await this.start();
@@ -124,7 +129,12 @@ class AgentOsx extends system_1.default {
124
129
  async update() {
125
130
  try {
126
131
  logger_1.default.info(texts_1.LOG_AGENT_STOPPING_SYSTEM);
127
- await this.stop();
132
+ try {
133
+ await this.stop();
134
+ }
135
+ catch {
136
+ // do nothing
137
+ }
128
138
  logger_1.default.info(texts_1.LOG_AGENT_SYSTEM_DIR);
129
139
  await this.ensureSystemConfigDir();
130
140
  logger_1.default.info(texts_1.LOG_AGENT_DOWNLOADING_ARCHIVE);
@@ -262,16 +262,11 @@ class AgentSystem {
262
262
  logger_1.default.changeRootPath(this.getNewAgentConfigDir());
263
263
  logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_STARTED);
264
264
  output_1.default.normal(texts_1.TXT_AGENT_STANDALONE_STARTED);
265
- const onProcessExit = () => {
265
+ manager_1.default.start(json.id, json.host, json.token, json.port, () => {
266
266
  logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_EXITING);
267
267
  output_1.default.normal(texts_1.TXT_AGENT_STANDALONE_EXITING);
268
268
  this.clearStandaloneProcConfig();
269
- process.exit(0);
270
- };
271
- process.on('SIGINT', onProcessExit);
272
- process.on('SIGTERM', onProcessExit);
273
- process.on('SIGQUIT', onProcessExit);
274
- manager_1.default.start(json.id, json.host, json.token, json.port);
269
+ });
275
270
  }
276
271
  clearStandaloneProcConfig() {
277
272
  try {
@@ -64,7 +64,12 @@ class AgentWindows extends system_1.default {
64
64
  async update() {
65
65
  try {
66
66
  logger_1.default.info(texts_1.LOG_AGENT_STOPPING_SYSTEM);
67
- await this.stop();
67
+ try {
68
+ await this.stop();
69
+ }
70
+ catch {
71
+ // do nothing
72
+ }
68
73
  logger_1.default.info(texts_1.LOG_AGENT_SYSTEM_DIR);
69
74
  await this.ensureSystemConfigDir();
70
75
  logger_1.default.info(texts_1.LOG_AGENT_DOWNLOADING_ARCHIVE);
@@ -87,7 +92,12 @@ class AgentWindows extends system_1.default {
87
92
  async changeUser(user, pass) {
88
93
  try {
89
94
  logger_1.default.info(texts_1.LOG_AGENT_STOPPING_SYSTEM);
90
- await this.stop();
95
+ try {
96
+ await this.stop();
97
+ }
98
+ catch {
99
+ // do nothing
100
+ }
91
101
  if (user && pass) {
92
102
  await this.nssm(`set bdy ObjectName ${user} ${pass}`);
93
103
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.22.4-dev",
4
+ "version": "1.22.5-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {