[Unit]
Description=Main REST Service for Glasses AI
After=rest.vector.service
Requires=rest.vector.service

[Service]
User=user
Group=user

# User=fermat
# Group=fermat

WorkingDirectory=/home/user/a2tec/glasses_ai
# WorkingDirectory=/home/fermat/project/FM_TEST_REST_SERVER

# 51002 포트가 열릴 때까지 대기 (bash 내장 TCP 체크 활용)
ExecStartPre=/bin/bash -c 'until timeout 1s bash -c "cat < /dev/null > /dev/tcp/localhost/51002"; do echo "Waiting for Vector Service on port 51002..."; sleep 2; done'

# rest 가상환경 파이썬 사용
ExecStart=/home/user/anaconda3/envs/rest/bin/python rest_main.py
# ExecStart=/mnt/clover_1TB/anaconda_data/fm_rest/bin/python rest_main.py
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target