COMING SOON 🚀

리자

[그누6실서비스] 4/8 - 시스템 유닛 파일 작성

시스템 서비스 유닛 파일 작성하기

 

[code]

ubuntu@sirsoft-235928:~/g6$ sudo su


root@sirsoft-235928:/home/ubuntu/g6# vi /etc/systemd/system/uvicorn.service

 

root@sirsoft-235928:/home/ubuntu/g6# systemctl daemon-reload


root@sirsoft-235928:/home/ubuntu/g6# systemctl restart uvicorn.service 


root@sirsoft-235928:/home/ubuntu/g6# systemctl status uvicorn.service 
● uvicorn.service - Uvicorn server with virtual environment
     Loaded: loaded (/etc/systemd/system/uvicorn.service; disabled; vendor preset: enabled)
     Active: active (running) since Thu 2024-01-18 12:20:14 KST; 8s ago

...

# Active: active (running) 이 나와야 정상 작동 하는 것입니다.

 

# 시스템 부팅시 자동으로 시작하도록 설정하는 데 사용합니다.

root@sirsoft-235928:/home/ubuntu/g6#  systemctl enable uvicorn.service
Created symlink /etc/systemd/system/multi-user.target.wants/uvicorn.service → /etc/systemd/system/uvicorn.service.

[/code]

 

 

/etc/systemd/system/uvicorn.service

[code]

[Unit]
Description=Uvicorn server with virtual environment
After=network.target

 

[Service]
User=ubuntu
Group=ubuntu
WorkingDirectory=/home/ubuntu/g6
Environment="PATH=/home/ubuntu/g6/venv/bin"
ExecStart=/home/ubuntu/g6/venv/bin/uvicorn main:app --host 0.0.0.0 --port 8000 --log-config log_config.ini

 

[Install]
WantedBy=multi-user.target
[/code]

 

 

다음글에 이어집니다.

|

댓글 2개

리자님의 글을 보고 열심히 배우고 있는 중에 다음과 같은 오류가 생겨서 문의를 드립니다.

 

=====오류 내용=====

root@stmlscd-280534:/home/ubuntu/g6# systemctl status uvicorn.service
× uvicorn.service - Uvicorn server with virtual environment
     Loaded: loaded (/etc/systemd/system/uvicorn.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sat 2025-05-10 14:15:21 KST; 20s ago
    Process: 32618 ExecStart=/home/ubuntu/g6/venv/bin/uvicorn main:app --host 0.0.0.0 --port 8000 --log-config log_config.ini (code=exited, status=1/FAILURE)
   Main PID: 32618 (code=exited, status=1/FAILURE)
        CPU: 52ms

May 10 14:15:21 stmlscd-280534 uvicorn[32618]:     self.configure_logging()
May 10 14:15:21 stmlscd-280534 uvicorn[32618]:   File "/home/ubuntu/g6/venv/lib/python3.10/site-packages/uvicorn/config.py", line 382, in configure_logging
May 10 14:15:21 stmlscd-280534 uvicorn[32618]:     logging.config.fileConfig(self.log_config, disable_existing_loggers=False)
May 10 14:15:21 stmlscd-280534 uvicorn[32618]:   File "/usr/lib/python3.10/logging/config.py", line 81, in fileConfig
May 10 14:15:21 stmlscd-280534 uvicorn[32618]:     _install_loggers(cp, handlers, disable_existing_loggers)
May 10 14:15:21 stmlscd-280534 uvicorn[32618]:   File "/usr/lib/python3.10/logging/config.py", line 206, in _install_loggers
May 10 14:15:21 stmlscd-280534 uvicorn[32618]:     log.addHandler(handlers[hand])
May 10 14:15:21 stmlscd-280534 uvicorn[32618]: KeyError: 'tiemdFile'
May 10 14:15:21 stmlscd-280534 systemd[1]: uvicorn.service: Main process exited, code=exited, status=1/FAILURE
May 10 14:15:21 stmlscd-280534 systemd[1]: uvicorn.service: Failed with result 'exit-code'.
 

ChatGPT와 논의를 하면서 오타로 인한 에러를 발견해서 수정한 후에 성공적으로 해결했습니다.

댓글을 작성하시려면 로그인이 필요합니다.

그누보드6 팁자료실

그누보드6, 파이썬에 대한 팁과 자료를 올려주세요. 그누보드6 실서비스를 위한 웹서버 설정

+
제목 글쓴이 날짜 조회
2년 전 조회 1,310
2년 전 조회 1,542
2년 전 조회 1,192
2년 전 조회 1,040
2년 전 조회 1,289
2년 전 조회 950
2년 전 조회 1,413
2년 전 조회 929
2년 전 조회 781
2년 전 조회 1,263
2년 전 조회 1,325
2년 전 조회 893
2년 전 조회 1,363
2년 전 조회 1,040
2년 전 조회 1,999
2년 전 조회 880
2년 전 조회 1,285
2년 전 조회 1,672
2년 전 조회 1,181
2년 전 조회 1,540
2년 전 조회 1,376
2년 전 조회 1,556
2년 전 조회 1,128
2년 전 조회 2,258
2년 전 조회 2,051
2년 전 조회 1,303
2년 전 조회 794
2년 전 조회 1,007
2년 전 조회 2,638
2년 전 조회 3,348