From e66179a267889c9a0021a4650382ad99bcfd60dc Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 26 Feb 2024 12:08:23 +0500 Subject: [PATCH] add new installer --- install.sh | 13 ------------- installer.sh | 29 +++++++++++++++++++++++++++++ run.sh | 4 ---- src/app.py | 2 +- 4 files changed, 30 insertions(+), 18 deletions(-) delete mode 100644 install.sh create mode 100644 installer.sh delete mode 100644 run.sh diff --git a/install.sh b/install.sh deleted file mode 100644 index d419579..0000000 --- a/install.sh +++ /dev/null @@ -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 diff --git a/installer.sh b/installer.sh new file mode 100644 index 0000000..5f4f450 --- /dev/null +++ b/installer.sh @@ -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 < /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 diff --git a/run.sh b/run.sh deleted file mode 100644 index 45260b1..0000000 --- a/run.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -source venv/bin/activate -python3 src/app.py diff --git a/src/app.py b/src/app.py index 5a8e76e..489f4a7 100644 --- a/src/app.py +++ b/src/app.py @@ -44,7 +44,7 @@ def login(): def get_logs(): issue_type = request.args.get("issue_type") 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) if issue_type not in config: return jsonify({"error": "Invalid issue type"})