Skip to content

Deployment on RHEL based distro

Bhavyai Gupta edited this page May 21, 2022 · 1 revision

Database setup

  1. Make sure you have mysql installed and setup on your system. If not, you can get mysql using package manager, and follow the setup instructions given on the official documentation.

    # dnf install community-mysql-server
    
  2. Download the file 01_init.sql from the budlib-api repository, and execute it.

    $ mysql -u root -h localhost -p
    
    > source 01_init.sql
    > exit
    
  3. Enable the mysql server to run on startup

    # systemctl enable mysqld.service
    

API setup

  1. Make sure you have jdk installed and setup on your system. If not, you can get jdk from https://adoptium.net/temurin/releases.

  2. Download the latest JAR of budlib-api from https://github.com/budlib/budlib-api/releases into your system, and put it in the below location.

    /usr/local/bin/budlib-api/api-<version>.jar
    
  3. Create a script that would run the downloaded JAR file

    # touch /usr/local/bin/budlib-api.sh
    
    # chmod +x /usr/local/bin/budlib-api.sh
    
  4. Add the following content in the file created in Step 3. Make sure to update the path to your installed jdk in the below content (jdk path our case the path is /opt/jdk-11.0.11+9/bin)

    #!/bin/bash
    
    export PATH="${PATH}:/opt/jdk-11.0.11+9/bin"
    nohup `which java` -jar /usr/local/bin/budlib-api/api-<version>.jar
    
  5. Create a service file for the budlib-api, that would run the API on system start-up

    # touch /etc/systemd/system/budlib-api.service
    
  6. Add the content in the file created in Step 5, as shown:

    [Unit]
    Description=REST API for BudLib
    Wants=network.target mysqld.service
    After=syslog.target network-online.target mysqld.service
    
    [Service]
    Type=simple
    User=$USER
    ExecStart=/usr/local/bin/budlib-api.sh
    Restart=on-failure
    RestartSec=10
    KillMode=mixed
    
    [Install]
    WantedBy=multi-user.target
    

    Note: replace $USER with your system username, or root

  7. Enable the budlib-api to run on system startup

    # systemctl daemon-reload
    # systemctl enable budlib-api.service
    

Clone this wiki locally