-
Notifications
You must be signed in to change notification settings - Fork 26
/
install.sh
33 lines (25 loc) 路 711 Bytes
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
SERVICE_NAME="chatnio-blob-service"
CURRENT_DIR=$(pwd)
echo "#!/bin/bash
cd $CURRENT_DIR
uvicorn main:app --host 0.0.0.0 --port 8100" > start.sh
chmod +x start.sh
SCRIPT="$CURRENT_DIR/start.sh"
cat << EOF > /etc/systemd/system/"$SERVICE_NAME".service
[Unit]
Description=$SERVICE_NAME
After=network.target
[Service]
ExecStart=$SCRIPT
User=root
Restart=always
[Install]
WantedBy=multi-user.target
EOF
echo "$SERVICE_NAME.service file created at /etc/systemd/system/$SERVICE_NAME.service"
echo "Registering and starting the service."
sudo systemctl daemon-reload
sudo systemctl start $SERVICE_NAME.service
sudo systemctl enable $SERVICE_NAME.service
sudo systemctl status $SERVICE_NAME.service