Ubuntu 20.04.6 LTS

 

1. 서비스 파일 만들기 

/etc/systemd/system 디렉토리에 파일을 만든다.

 

vi myservice.service

[Unit]
Description=서비스 설명 
Wants=network.target
After=network.target

[Service]
Type=simple
WorkingDirectory=작업디렉토리 /home/ubuntu/myservice
Environment="PATH=/home/ubuntu/.nvm/versions/node/v16.10.0/bin:$PATH"
ExecStart=/opt/conda/envs/pytorch/bin/uvicorn main:app --reload --host=0.0.0.0 --port=8000
Restart=on-failure
RestartSec=3s
StandardOutput=file:/var/log/myservice/log.log
StandardError=file:/var/log/myservice/log.log

[Install]
WantedBy=multi-user.target

 

2. 서비스 등록 및 실행

* 서비스 데몬 재실행

systemctl daemon-reload

 

* 서비스활성화

systemctl enable myservice.service

 

* 서비스 시작

systemctl start myservice.service

 

* 서비스 상태 확인

systemctl status myservice.service

 

3. 트러블슈팅

로그 파일 경로의 디렉토리가 없다면 만들어준다.

 

 

참고 https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html



python 모듈 설치하는데 아래와 같이 뜨더군요



gcc-pthread -fno-strict-aliasing-DNDEBUG -g-fwrapv -O2 -Wall -Wstrict-prototypes-fPIC -I/usr/include/python2.7 -c lib/sqlalchemy/cextension/processors.c -o build/temp.linux-x86_64-2.7/lib/sqlalchemy/cextension/processors.o

lib/sqlalchemy/cextension/processors.c:10:20: fatal error:Python.h:Nosuchfileor directory

compilation terminated.

***************************************************************************

command'gcc'failed withexit status1

WARNING: TheC extension could not be compiled,speedups arenot enabled.

Failure information,ifany,is above.

Retrying the buildwithout the C extensionnow.

***************************************************************************


python-dev만 설치해주면 간단히 해결됩니다


sudo apt-get install python-dev


+ Recent posts