et al/AI Tech 6

[Airflow] airflow.exceptions.AirflowException: The webserver is already running under PID 에러 해결

코딩상륙작전 2024. 3. 3. 10:39

* airflow webserver 에러

로컬에서 python3 venv 가상환경에서 airflow를 실행시키려고 하는데, 

airflow webserver --port 8080

아래와 같은 에러가 떴다.

 

AirflowException(f"The {process_name} is already running under PID {pid}.")

airflow.exceptions.AirflowException: The webserver is already running under PID

 

계속 이미 진행중인 PID가 있다는 것인데 kill -9 PID 명령어로 프로세스를 종료시키려고해도 소용이 없어서, 더 찾아보니 아래와 같은 명령어로 해결할 수 있었다.

killall -9 airflow

 

ps aux |grep 명령어로 airflow가 모두 잘 종료되었는지 확인할 수 있다.

ps aux |grep PID #PID 일치하는 프로세스 검색
ps aux | grep airflow # airflow라는 이름을 가진 프로세스 검색

 

* airflow scheduler 에러

스케쥴러를 재실행하려고 했는데 다음과 같은 에러가 발생했다.

[ERROR] Connection in use: ('::', 8793)

아래 명령어들로 프로세스를 종료후, 다시 실행했더니 잘 잡혔다.

# 8793 port를 검색
# PID/프로세스명 확인
sudo netstat -anp | grep 8793 # 
tcp6       0      0 :::8793                 :::*                    LISTEN      15150/gunicorn: mas

# 15150 PID를 검색
ps aux |grep 15150
hd         15150  0.0  0.3 151216 103896 pts/1   S    10:43   0:00 gunicorn: master [gunicorn]
hd         18451  0.0  0.0  10340  2836 pts/1    S+   11:02   0:00 grep --color=auto 15150

# 15150 PID를 강제 종료
kill -9 15150

# 강제 종료 잘 됐는 지 다시 한 번 확인
ps aux |grep 15150
hd         18490  0.0  0.0  10340   724 pts/1    S+   11:03   0:00 grep --color=auto 15150