add new installer

This commit is contained in:
Your Name 2024-02-26 12:08:23 +05:00
parent e04959e7ae
commit e66179a267
4 changed files with 30 additions and 18 deletions

View File

@ -1,13 +0,0 @@
#!/bin/bash
if ! command -v python3 &> /dev/null
then
echo "Error: python3 could not be found"
exit
else
python3 -m venv venv
source venv/bin/activate
pip install Flask
pip install flask_jwt_extended
chmod +x run.sh
fi

29
installer.sh Normal file
View File

@ -0,0 +1,29 @@
# Clone the repository
git clone https://git.maxprint.io/MaxApex/ticket_ai_flask_app.git /opt/ticket-ai
# navigate to the repo
cd /opt/ticket-ai
# Create virtual environment
python3 -m venv /opt/ticket-ai/venv
# Activate virtual environment and install Flask and flask_jwt_extended
source /opt/ticket-ai/venv/bin/activate
pip install Flask
pip install flask_jwt_extended
# Create systemd service file
cat <<EOF > /etc/systemd/system/ticket-ai.service
[Unit]
Description=Ticket AI
[Service]
Type=simple
ExecStart=/opt/ticket-ai/venv/bin/python3 /opt/ticket-ai/src/app.py
[Install]
WantedBy=multi-user.target
EOF
# Start the service
systemctl start ticket-ai.service

4
run.sh
View File

@ -1,4 +0,0 @@
#!/bin/bash
source venv/bin/activate
python3 src/app.py

View File

@ -44,7 +44,7 @@ def login():
def get_logs(): def get_logs():
issue_type = request.args.get("issue_type") issue_type = request.args.get("issue_type")
try: try:
with open('./src/config.json') as config_file: with open('/opt/ticket-ai/src/config.json') as config_file:
config = json.load(config_file) config = json.load(config_file)
if issue_type not in config: if issue_type not in config:
return jsonify({"error": "Invalid issue type"}) return jsonify({"error": "Invalid issue type"})