NodeRed

nodered죽는 현상 해결 방법

아이티제어1998 2022. 9. 29. 09:40

0.bat파일

cd C:\Users\Administrator\.node-red
node-red -s settings1880.js -p 1880 --location=global​

2.bat파일

cd C:\Users\Administrator\.node-red
node-red -s settings1882.js -p 1882 --location=global​

check02.bat 파일

@echo off
rem  /* check02.bat 파일
rem  기능:1880포트 실행확인 없을시 0.bat 실행 
rem  기능:1882포트 실행확인 없을시 2.bat 실행 
rem */
:START

netstat -ano | find "1880" | find "LISTEN" > NUL
if not ERRORLEVEL 1 (
	echo 1880 포트실행중.
	goto CK1880
) else (
	echo Not Run.
	goto GGNG

);

:PGOK
	timeout /t 15
	goto START

:GGNG
	start cmd /k  call "C:\Users\Administrator\.node-red\0.bat"
	echo Restart . %DATE% %TIME% >> c:\exec1880Log.txt
	timeout /t 60
	goto START


:CK1880
	
netstat -ano | find "1882" | find "LISTEN" > NUL
if not ERRORLEVEL 1 (
	echo 1882 포트실행중.
	goto PGOK
) else (
	echo Not Run.
	start cmd /k  call "C:\Users\Administrator\.node-red\2.bat"
	echo Restart . %DATE% %TIME% >> c:\exec1882Log.txt
	timeout /t 60
	goto START

);

nodered데몬이  여러 가지 이유로 인해  죽는경우가 계속 발생한다..

주된 원인은   스크립트 오류의 에러처리가   try catch  error 만사용하고 finally 처리를 안해주면 죽게된다.

그렇다고  module 만드는분들에게  finally를 꼭 넣으셔요 라고 할수도없다.

 

해결법으로 사용한 스크립트이다.

1880 포트와 1882 두개의 포트로 각각 다른  서비스를 돌리고 있고

두개 포트를 각각 체크해서 새로 실행하도록 하였다.

check02.bat 실행화면

 

 

2.bat 실행 로그 1882포트
0.bat실행 로그

 

끝.