리자

[그누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,288
2년 전 조회 1,529
2년 전 조회 1,178
2년 전 조회 1,028
2년 전 조회 1,279
2년 전 조회 937
2년 전 조회 1,402
2년 전 조회 912
2년 전 조회 770
2년 전 조회 1,250
2년 전 조회 1,307
2년 전 조회 885
2년 전 조회 1,350
2년 전 조회 1,028
2년 전 조회 1,989
2년 전 조회 866
2년 전 조회 1,271
2년 전 조회 1,636
2년 전 조회 1,170
2년 전 조회 1,521
2년 전 조회 1,366
2년 전 조회 1,547
2년 전 조회 1,114
2년 전 조회 2,244
2년 전 조회 2,041
2년 전 조회 1,281
2년 전 조회 781
2년 전 조회 988
2년 전 조회 2,611
2년 전 조회 3,309