곽원석

Update app.js (기능분화)

Showing 1 changed file with 611 additions and 15 deletions
...@@ -4,7 +4,7 @@ var express = require('express'); ...@@ -4,7 +4,7 @@ var express = require('express');
4 // 요청 리소스 표현 모듈 4 // 요청 리소스 표현 모듈
5 var request = require('request'); 5 var request = require('request');
6 6
7 -// api 데이터포맷이 xml이므로 json으로 파싱할 필요가 있음 7 +// api로 받아올 데이터포맷이 xml이므로 json으로 파싱할 필요가 있음
8 var convert = require('xml-js'); 8 var convert = require('xml-js');
9 const bodyParser = require('body-parser'); 9 const bodyParser = require('body-parser');
10 10
...@@ -15,6 +15,12 @@ const TOKEN = 'OPv3udmn1UGx+xWZFm80KeZbeGJm63nyt+sTpvBr1Mbc1Y0FAeK4MohQLcWq5yytJ ...@@ -15,6 +15,12 @@ const TOKEN = 'OPv3udmn1UGx+xWZFm80KeZbeGJm63nyt+sTpvBr1Mbc1Y0FAeK4MohQLcWq5yytJ
15 // 공공보건포털_API 15 // 공공보건포털_API
16 const CORONA_URL = 'http://openapi.data.go.kr/openapi/service/rest/Covid19/getCovid19InfStateJson'; 16 const CORONA_URL = 'http://openapi.data.go.kr/openapi/service/rest/Covid19/getCovid19InfStateJson';
17 const SERVICE_KEY = 'DMUPOq6b%2B%2F1gqfLEXQ6bnhgoTO73BfPprA6HVNcV%2F6vHMGG%2Bgiw%2BPDkPvX1eQ7b9uvl%2B42fxUPkU0W3Si907Lw%3D%3D' 17 const SERVICE_KEY = 'DMUPOq6b%2B%2F1gqfLEXQ6bnhgoTO73BfPprA6HVNcV%2F6vHMGG%2Bgiw%2BPDkPvX1eQ7b9uvl%2B42fxUPkU0W3Si907Lw%3D%3D'
18 +queryParams = '?' + encodeURIComponent('ServiceKey') + '=' + SERVICE_KEY; // Service Key
19 +queryParams += '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent('1');
20 +queryParams += '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent('4');
21 +var date;
22 +var menu = 0;
23 +var start_checker = false;
18 24
19 // express 미들웨어 정의 25 // express 미들웨어 정의
20 var app = express(); 26 var app = express();
...@@ -28,8 +34,6 @@ const { measureMemory } = require('vm'); ...@@ -28,8 +34,6 @@ const { measureMemory } = require('vm');
28 const domain = "www.oss-chatbot-kwak.tk" 34 const domain = "www.oss-chatbot-kwak.tk"
29 const sslport = 23023; 35 const sslport = 23023;
30 36
31 -var date;
32 -
33 // 챗봇으로 입력 37 // 챗봇으로 입력
34 app.post('/hook', function (req, res) { 38 app.post('/hook', function (req, res) {
35 39
...@@ -43,7 +47,7 @@ app.post('/hook', function (req, res) { ...@@ -43,7 +47,7 @@ app.post('/hook', function (req, res) {
43 console.log('[request source] ', eventObj.source); 47 console.log('[request source] ', eventObj.source);
44 console.log('[request message]', eventObj.message); 48 console.log('[request message]', eventObj.message);
45 49
46 - // 50 + // 챗봇시작
47 if(message.text == '/코로나' || message.text == '/corona'){ 51 if(message.text == '/코로나' || message.text == '/corona'){
48 request.post( 52 request.post(
49 { 53 {
...@@ -56,6 +60,223 @@ app.post('/hook', function (req, res) { ...@@ -56,6 +60,223 @@ app.post('/hook', function (req, res) {
56 "messages":[ 60 "messages":[
57 { 61 {
58 "type":"text", 62 "type":"text",
63 + "text":"명령어 : /코로나 or /corona 로 코로나 19 bot을 시작하셨습니다."
64 + },
65 + {
66 + "type":"text",
67 + "text":"명령어 :\n1. 확진자 수 :\t/확진자\n2. 격리해제 수 :\t/격리해제\n3. 검사진행 수 :\t/검사진행\n4. 사망자 수 :\t/사망자\n5. 치료중 환자 수 :\t/치료중\n6. 결과음성 수 :\t/결과음성\n7. 누적검사 수 :\t/누적검사\n8. 누적 확진률 :\t/누적확진\n"
68 + }
69 + ]
70 + }
71 + },(error, response, body) => {
72 + console.log(body)
73 + });
74 + start_checker = true;
75 + return;
76 + }
77 + else if(message.text == '/확진자' && start_checker == true){
78 + menu = 1;
79 + start_checker = false;
80 + request.post(
81 + {
82 + url: TARGET_URL,
83 + headers: {
84 + 'Authorization': `Bearer ${TOKEN}`
85 + },
86 + json: {
87 + "replyToken":eventObj.replyToken,
88 + "messages":[
89 + {
90 + "type":"text",
91 + "text":"확인하고 싶으신 일자를 적어주세요."
92 + },
93 + {
94 + "type":"text",
95 + "text":"예시) 20201209"
96 + }
97 + ]
98 + }
99 + },(error, response, body) => {
100 + console.log(body)
101 + });
102 + return;
103 + }
104 + else if(message.text == '/격리해제' && start_checker == true){
105 + menu = 2;
106 + start_checker = false;
107 + request.post(
108 + {
109 + url: TARGET_URL,
110 + headers: {
111 + 'Authorization': `Bearer ${TOKEN}`
112 + },
113 + json: {
114 + "replyToken":eventObj.replyToken,
115 + "messages":[
116 + {
117 + "type":"text",
118 + "text":"확인하고 싶으신 일자를 적어주세요."
119 + },
120 + {
121 + "type":"text",
122 + "text":"예시) 20201209"
123 + }
124 + ]
125 + }
126 + },(error, response, body) => {
127 + console.log(body)
128 + });
129 + return;
130 + }
131 + else if(message.text == '/검사진행' && start_checker == true){
132 + menu = 3;
133 + start_checker = false;
134 + request.post(
135 + {
136 + url: TARGET_URL,
137 + headers: {
138 + 'Authorization': `Bearer ${TOKEN}`
139 + },
140 + json: {
141 + "replyToken":eventObj.replyToken,
142 + "messages":[
143 + {
144 + "type":"text",
145 + "text":"확인하고 싶으신 일자를 적어주세요."
146 + },
147 + {
148 + "type":"text",
149 + "text":"예시) 20201209"
150 + }
151 + ]
152 + }
153 + },(error, response, body) => {
154 + console.log(body)
155 + });
156 + return;
157 + }
158 + else if(message.text == '/사망자' && start_checker == true){
159 + menu = 4;
160 + start_checker = false;
161 + request.post(
162 + {
163 + url: TARGET_URL,
164 + headers: {
165 + 'Authorization': `Bearer ${TOKEN}`
166 + },
167 + json: {
168 + "replyToken":eventObj.replyToken,
169 + "messages":[
170 + {
171 + "type":"text",
172 + "text":"확인하고 싶으신 일자를 적어주세요."
173 + },
174 + {
175 + "type":"text",
176 + "text":"예시) 20201209"
177 + }
178 + ]
179 + }
180 + },(error, response, body) => {
181 + console.log(body)
182 + });
183 + return;
184 + }
185 + else if(message.text == '/치료중' && start_checker == true){
186 + menu = 5;
187 + start_checker = false;
188 + request.post(
189 + {
190 + url: TARGET_URL,
191 + headers: {
192 + 'Authorization': `Bearer ${TOKEN}`
193 + },
194 + json: {
195 + "replyToken":eventObj.replyToken,
196 + "messages":[
197 + {
198 + "type":"text",
199 + "text":"확인하고 싶으신 일자를 적어주세요."
200 + },
201 + {
202 + "type":"text",
203 + "text":"예시) 20201209"
204 + }
205 + ]
206 + }
207 + },(error, response, body) => {
208 + console.log(body)
209 + });
210 + return;
211 + }
212 + else if(message.text == '/음성' && start_checker == true){
213 + menu = 6;
214 + start_checker = false;
215 + request.post(
216 + {
217 + url: TARGET_URL,
218 + headers: {
219 + 'Authorization': `Bearer ${TOKEN}`
220 + },
221 + json: {
222 + "replyToken":eventObj.replyToken,
223 + "messages":[
224 + {
225 + "type":"text",
226 + "text":"확인하고 싶으신 일자를 적어주세요."
227 + },
228 + {
229 + "type":"text",
230 + "text":"예시) 20201209"
231 + }
232 + ]
233 + }
234 + },(error, response, body) => {
235 + console.log(body)
236 + });
237 + return;
238 + }
239 + else if(message.text == '/누적검사' && start_checker == true){
240 + menu = 7;
241 + start_checker = false;
242 + request.post(
243 + {
244 + url: TARGET_URL,
245 + headers: {
246 + 'Authorization': `Bearer ${TOKEN}`
247 + },
248 + json: {
249 + "replyToken":eventObj.replyToken,
250 + "messages":[
251 + {
252 + "type":"text",
253 + "text":"확인하고 싶으신 일자를 적어주세요."
254 + },
255 + {
256 + "type":"text",
257 + "text":"예시) 20201209"
258 + }
259 + ]
260 + }
261 + },(error, response, body) => {
262 + console.log(body)
263 + });
264 + return;
265 + }
266 + else if(message.text == '/누적확진' && start_checker == true){
267 + menu = 8;
268 + start_checker = false;
269 + request.post(
270 + {
271 + url: TARGET_URL,
272 + headers: {
273 + 'Authorization': `Bearer ${TOKEN}`
274 + },
275 + json: {
276 + "replyToken":eventObj.replyToken,
277 + "messages":[
278 + {
279 + "type":"text",
59 "text":"확인하고 싶으신 일자를 적어주세요." 280 "text":"확인하고 싶으신 일자를 적어주세요."
60 }, 281 },
61 { 282 {
...@@ -69,21 +290,88 @@ app.post('/hook', function (req, res) { ...@@ -69,21 +290,88 @@ app.post('/hook', function (req, res) {
69 }); 290 });
70 return; 291 return;
71 } 292 }
72 - else 293 + else if(start_checker == true){
294 + menu = 0;
295 + request.post(
296 + {
297 + url: TARGET_URL,
298 + headers: {
299 + 'Authorization': `Bearer ${TOKEN}`
300 + },
301 + json: {
302 + "replyToken":eventObj.replyToken,
303 + "messages":[
73 { 304 {
305 + "type":"text",
306 + "text":"선택하신 정보가 정확하지 않거나 없습니다.\\n처음부터 다시 진행해주세요."
307 + },
308 + ]
309 + }
310 + },(error, response, body) => {
311 + console.log(body)
312 + });
313 + start_checker = false;
314 + return;
315 + }
316 +
317 + if((menu != 0) && (message.text)){
74 date = message.text; 318 date = message.text;
75 - queryParams = '?' + encodeURIComponent('ServiceKey') + '=' + SERVICE_KEY; /* Service Key*/
76 - queryParams += '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent('1'); /* */
77 - queryParams += '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent('4'); /* */
78 queryParams += '&' + encodeURIComponent('startCreateDt') + '=' + encodeURIComponent(date); 319 queryParams += '&' + encodeURIComponent('startCreateDt') + '=' + encodeURIComponent(date);
79 - queryParams += '&' + encodeURIComponent('endCreateDt') + '=' + encodeURIComponent(date); /* */ 320 + queryParams += '&' + encodeURIComponent('endCreateDt') + '=' + encodeURIComponent(date);
80 - bot_reply(eventObj.replyToken, message); 321 + switch(menu){
81 - res.sendStatus(200); 322 + case 1:
323 + bot_reply_1(eventObj.replyToken, message);
324 + break;
325 + case 2:
326 + bot_reply_2(eventObj.replyToken, message);
327 + break;
328 + case 3:
329 + bot_reply_3(eventObj.replyToken, message);
330 + break;
331 + case 4:
332 + bot_reply_4(eventObj.replyToken, message);
333 + break;
334 + case 5:
335 + bot_reply_5(eventObj.replyToken, message);
336 + break;
337 + case 6:
338 + bot_reply_6(eventObj.replyToken, message);
339 + break;
340 + case 7:
341 + bot_reply_7(eventObj.replyToken, message);
342 + break;
343 + case 8:
344 + bot_reply_8(eventObj.replyToken, message);
345 + break;
346 + default :
347 + break;
348 + }
349 + }
350 + else if(menu == 0){
351 + request.post(
352 + {
353 + url: TARGET_URL,
354 + headers: {
355 + 'Authorization': `Bearer ${TOKEN}`
356 + },
357 + json: {
358 + "replyToken":eventObj.replyToken,
359 + "messages":[
360 + {
361 + "type":"text",
362 + "text":"코로나 봇을 찾으시나요?\n명령어는 /코로나 또는 /corona 입니다."
363 + }
364 + ]
365 + }
366 + },(error, response, body) => {
367 + console.log(body)
368 + });
82 } 369 }
83 370
371 + res.sendStatus(200);
84 }); 372 });
85 373
86 -function bot_reply(replyToken, message) { 374 +function bot_reply_1(replyToken, message) {
87 request({ 375 request({
88 url: CORONA_URL + queryParams, 376 url: CORONA_URL + queryParams,
89 method: 'GET' 377 method: 'GET'
...@@ -108,12 +396,320 @@ function bot_reply(replyToken, message) { ...@@ -108,12 +396,320 @@ function bot_reply(replyToken, message) {
108 "messages":[ 396 "messages":[
109 { 397 {
110 "type":"text", 398 "type":"text",
111 - "text": '선택하신 날짜의 Corona Virus-19 현황은 다음과 같습니다.' 399 + "text": '선택하신 날짜와 정보의 Corona Virus-19 현황은 다음과 같습니다.'
400 + },
401 + {
402 + "type":"text",
403 + "text": "확진자 수 : " + resultMessage.decideCnt._text
404 + },
405 + {
406 + "type":"text",
407 + "text": "등록일시분초 : " + resultMessage.createDt._text
408 + }
409 + ]
410 + }
411 + },(error, response, body) => {
412 + console.log(body)
413 + });
414 + }
415 + });
416 +}
417 +function bot_reply_2(replyToken, message) {
418 + request({
419 + url: CORONA_URL + queryParams,
420 + method: 'GET'
421 + },(error, response, body) => {
422 + if(!error && response.statusCode == 200) {
423 + console.log('Status', response.statusCode);
424 + console.log('Headers', JSON.stringify(response.headers));
425 + var xmlToJson = convert.xml2json(response.body, {compact: true, spaces: 4});
426 + const jsonData = JSON.parse(xmlToJson); // json text -> json object
427 + console.log('Reponse received', xmlToJson); // json text
428 +
429 + var resultMessage = jsonData.response.body.items.item;
430 +
431 + request.post(
432 + {
433 + url: TARGET_URL,
434 + headers: {
435 + 'Authorization': `Bearer ${TOKEN}`
436 + },
437 + json: {
438 + "replyToken":replyToken,
439 + "messages":[
440 + {
441 + "type":"text",
442 + "text": '선택하신 날짜와 정보의 Corona Virus-19 현황은 다음과 같습니다.'
443 + },
444 + {
445 + "type":"text",
446 + "text": "격리해제 수 : " + resultMessage.clearCnt._text
447 + },
448 + {
449 + "type":"text",
450 + "text": "등록일시분초 : " + resultMessage.createDt._text
451 + }
452 + ]
453 + }
454 + },(error, response, body) => {
455 + console.log(body)
456 + });
457 + }
458 + });
459 +}
460 +function bot_reply_3(replyToken, message) {
461 + request({
462 + url: CORONA_URL + queryParams,
463 + method: 'GET'
464 + },(error, response, body) => {
465 + if(!error && response.statusCode == 200) {
466 + console.log('Status', response.statusCode);
467 + console.log('Headers', JSON.stringify(response.headers));
468 + var xmlToJson = convert.xml2json(response.body, {compact: true, spaces: 4});
469 + const jsonData = JSON.parse(xmlToJson); // json text -> json object
470 + console.log('Reponse received', xmlToJson); // json text
471 +
472 + var resultMessage = jsonData.response.body.items.item;
473 +
474 + request.post(
475 + {
476 + url: TARGET_URL,
477 + headers: {
478 + 'Authorization': `Bearer ${TOKEN}`
479 + },
480 + json: {
481 + "replyToken":replyToken,
482 + "messages":[
483 + {
484 + "type":"text",
485 + "text": '선택하신 날짜와 정보의 Corona Virus-19 현황은 다음과 같습니다.'
486 + },
487 + {
488 + "type":"text",
489 + "text": "검사진행 수 : " + resultMessage.examCnt._text
490 + },
491 + {
492 + "type":"text",
493 + "text": "등록일시분초 : " + resultMessage.createDt._text
494 + }
495 + ]
496 + }
497 + },(error, response, body) => {
498 + console.log(body)
499 + });
500 + }
501 + });
502 +}
503 +function bot_reply_4(replyToken, message) {
504 + request({
505 + url: CORONA_URL + queryParams,
506 + method: 'GET'
507 + },(error, response, body) => {
508 + if(!error && response.statusCode == 200) {
509 + console.log('Status', response.statusCode);
510 + console.log('Headers', JSON.stringify(response.headers));
511 + var xmlToJson = convert.xml2json(response.body, {compact: true, spaces: 4});
512 + const jsonData = JSON.parse(xmlToJson); // json text -> json object
513 + console.log('Reponse received', xmlToJson); // json text
514 +
515 + var resultMessage = jsonData.response.body.items.item;
516 +
517 + request.post(
518 + {
519 + url: TARGET_URL,
520 + headers: {
521 + 'Authorization': `Bearer ${TOKEN}`
522 + },
523 + json: {
524 + "replyToken":replyToken,
525 + "messages":[
526 + {
527 + "type":"text",
528 + "text": '선택하신 날짜와 정보의 Corona Virus-19 현황은 다음과 같습니다.'
529 + },
530 + {
531 + "type":"text",
532 + "text": "사망자 수 : " + resultMessage.deathCnt._text
533 + },
534 + {
535 + "type":"text",
536 + "text": "등록일시분초 : " + resultMessage.createDt._text
537 + }
538 + ]
539 + }
540 + },(error, response, body) => {
541 + console.log(body)
542 + });
543 + }
544 + });
545 +}
546 +function bot_reply_5(replyToken, message) {
547 + request({
548 + url: CORONA_URL + queryParams,
549 + method: 'GET'
550 + },(error, response, body) => {
551 + if(!error && response.statusCode == 200) {
552 + console.log('Status', response.statusCode);
553 + console.log('Headers', JSON.stringify(response.headers));
554 + var xmlToJson = convert.xml2json(response.body, {compact: true, spaces: 4});
555 + const jsonData = JSON.parse(xmlToJson); // json text -> json object
556 + console.log('Reponse received', xmlToJson); // json text
557 +
558 + var resultMessage = jsonData.response.body.items.item;
112 559
560 + request.post(
561 + {
562 + url: TARGET_URL,
563 + headers: {
564 + 'Authorization': `Bearer ${TOKEN}`
565 + },
566 + json: {
567 + "replyToken":replyToken,
568 + "messages":[
569 + {
570 + "type":"text",
571 + "text": '선택하신 날짜와 정보의 Corona Virus-19 현황은 다음과 같습니다.'
572 + },
573 + {
574 + "type":"text",
575 + "text": "치료중 환자 수 : " + resultMessage.careCnt._text
576 + },
577 + {
578 + "type":"text",
579 + "text": "등록일시분초 : " + resultMessage.createDt._text
580 + }
581 + ]
582 + }
583 + },(error, response, body) => {
584 + console.log(body)
585 + });
586 + }
587 + });
588 +}
589 +function bot_reply_6(replyToken, message) {
590 + request({
591 + url: CORONA_URL + queryParams,
592 + method: 'GET'
593 + },(error, response, body) => {
594 + if(!error && response.statusCode == 200) {
595 + console.log('Status', response.statusCode);
596 + console.log('Headers', JSON.stringify(response.headers));
597 + var xmlToJson = convert.xml2json(response.body, {compact: true, spaces: 4});
598 + const jsonData = JSON.parse(xmlToJson); // json text -> json object
599 + console.log('Reponse received', xmlToJson); // json text
600 +
601 + var resultMessage = jsonData.response.body.items.item;
602 +
603 + request.post(
604 + {
605 + url: TARGET_URL,
606 + headers: {
607 + 'Authorization': `Bearer ${TOKEN}`
608 + },
609 + json: {
610 + "replyToken":replyToken,
611 + "messages":[
612 + {
613 + "type":"text",
614 + "text": '선택하신 날짜와 정보의 Corona Virus-19 현황은 다음과 같습니다.'
615 + },
616 + {
617 + "type":"text",
618 + "text": "결과 음성 수 : " + resultMessage.resutlNegCnt._text
619 + },
620 + {
621 + "type":"text",
622 + "text": "등록일시분초 : " + resultMessage.createDt._text
623 + }
624 + ]
625 + }
626 + },(error, response, body) => {
627 + console.log(body)
628 + });
629 + }
630 + });
631 +}
632 +function bot_reply_7(replyToken, message) {
633 + request({
634 + url: CORONA_URL + queryParams,
635 + method: 'GET'
636 + },(error, response, body) => {
637 + if(!error && response.statusCode == 200) {
638 + console.log('Status', response.statusCode);
639 + console.log('Headers', JSON.stringify(response.headers));
640 + var xmlToJson = convert.xml2json(response.body, {compact: true, spaces: 4});
641 + const jsonData = JSON.parse(xmlToJson); // json text -> json object
642 + console.log('Reponse received', xmlToJson); // json text
643 +
644 + var resultMessage = jsonData.response.body.items.item;
645 +
646 + request.post(
647 + {
648 + url: TARGET_URL,
649 + headers: {
650 + 'Authorization': `Bearer ${TOKEN}`
651 + },
652 + json: {
653 + "replyToken":replyToken,
654 + "messages":[
655 + {
656 + "type":"text",
657 + "text": '선택하신 날짜와 정보의 Corona Virus-19 현황은 다음과 같습니다.'
658 + },
659 + {
660 + "type":"text",
661 + "text": "누적 검사 수 : " + resultMessage.accExamCnt._text
662 + },
663 + {
664 + "type":"text",
665 + "text": "누적 검사 완료 수 : " + resultMessage.accExamCompCnt._text
666 + },
667 + {
668 + "type":"text",
669 + "text": "등록일시분초 : " + resultMessage.createDt._text
670 + }
671 + ]
672 + }
673 + },(error, response, body) => {
674 + console.log(body)
675 + });
676 + }
677 + });
678 +}
679 +function bot_reply_8(replyToken, message) {
680 + request({
681 + url: CORONA_URL + queryParams,
682 + method: 'GET'
683 + },(error, response, body) => {
684 + if(!error && response.statusCode == 200) {
685 + console.log('Status', response.statusCode);
686 + console.log('Headers', JSON.stringify(response.headers));
687 + var xmlToJson = convert.xml2json(response.body, {compact: true, spaces: 4});
688 + const jsonData = JSON.parse(xmlToJson); // json text -> json object
689 + console.log('Reponse received', xmlToJson); // json text
690 +
691 + var resultMessage = jsonData.response.body.items.item;
692 +
693 + request.post(
694 + {
695 + url: TARGET_URL,
696 + headers: {
697 + 'Authorization': `Bearer ${TOKEN}`
698 + },
699 + json: {
700 + "replyToken":replyToken,
701 + "messages":[
702 + {
703 + "type":"text",
704 + "text": '선택하신 날짜와 정보의 Corona Virus-19 현황은 다음과 같습니다.'
705 + },
706 + {
707 + "type":"text",
708 + "text": "누적 확진률 : " + resultMessage.accDefRate._text
113 }, 709 },
114 { 710 {
115 "type":"text", 711 "type":"text",
116 - "text": JSON.stringify(resultMessage) 712 + "text": "등록일시분초 : " + resultMessage.createDt._text
117 } 713 }
118 ] 714 ]
119 } 715 }
...@@ -124,7 +720,7 @@ function bot_reply(replyToken, message) { ...@@ -124,7 +720,7 @@ function bot_reply(replyToken, message) {
124 }); 720 });
125 } 721 }
126 722
127 -// 오류처리 723 +// Https server 오류처리
128 try { 724 try {
129 const option = { 725 const option = {
130 ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'), 726 ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'),
......