Compare commits
6 Commits
e9fb08f2ca
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 95c7bfe933 | |||
| 9d3cec7cf6 | |||
| d96ba361fc | |||
| 64d8d629fe | |||
| 4fd5335bdb | |||
| 87af07fc60 |
@@ -15,3 +15,9 @@ db['db'] = 'Database Name'
|
|||||||
#- db['data_path_mysql'] = '/var/lib/mysql'
|
#- db['data_path_mysql'] = '/var/lib/mysql'
|
||||||
#- db['data_path_mysql_backup'] = '/var/lib/mysql'
|
#- db['data_path_mysql_backup'] = '/var/lib/mysql'
|
||||||
#- db['port'] = 3306
|
#- db['port'] = 3306
|
||||||
|
#- db['host'] = localhost
|
||||||
|
|
||||||
|
## Api Configuration
|
||||||
|
api = {}
|
||||||
|
#- api['ip'] = '0.0.0.0'
|
||||||
|
#- api['port'] = 81
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ def template(filename, target_path):
|
|||||||
# Load Template
|
# Load Template
|
||||||
template = env.get_template(filename)
|
template = env.get_template(filename)
|
||||||
# Render Output
|
# Render Output
|
||||||
content = template.render(db=config.db)
|
content = template.render(db=config.db,api=config.api)
|
||||||
# Write Template to file
|
# Write Template to file
|
||||||
filename_without_ext = os.path.splitext(filename)[0]
|
filename_without_ext = os.path.splitext(filename)[0]
|
||||||
cooked_file = target_path+filename_without_ext
|
cooked_file = target_path+filename_without_ext
|
||||||
@@ -25,4 +25,7 @@ def template(filename, target_path):
|
|||||||
# Render the templates:
|
# Render the templates:
|
||||||
## Create Docker-Compose
|
## Create Docker-Compose
|
||||||
template("docker-compose.yml.j2", "./src/")
|
template("docker-compose.yml.j2", "./src/")
|
||||||
|
## Create API Config
|
||||||
|
template(".env.j2", "./bin/")
|
||||||
|
## Create Cleanup script
|
||||||
template("clean-data.sh.j2", "./src/")
|
template("clean-data.sh.j2", "./src/")
|
||||||
2
makefile
2
makefile
@@ -40,7 +40,7 @@ api: api-start
|
|||||||
api-init:
|
api-init:
|
||||||
cd src/api; go build -o ../../bin/engine_x_mgmt
|
cd src/api; go build -o ../../bin/engine_x_mgmt
|
||||||
api-start:
|
api-start:
|
||||||
./bin/engine_x_mgmt &
|
cd bin; ./engine_x_mgmt
|
||||||
api-stop:
|
api-stop:
|
||||||
|
|
||||||
# Setup UI
|
# Setup UI
|
||||||
|
|||||||
40
src/api/helper/11_QueryDB.go
Normal file
40
src/api/helper/11_QueryDB.go
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package helper
|
||||||
|
|
||||||
|
import (
|
||||||
|
"database/sql"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
_ "github.com/go-sql-driver/mysql"
|
||||||
|
)
|
||||||
|
|
||||||
|
func QueryString(queryStr string) []byte {
|
||||||
|
db_string := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s", Db_User, Db_Pass, Db_Host, Db_Port, Db_Default_Db)
|
||||||
|
conn, err := sql.Open("mysql", db_string)
|
||||||
|
if err != nil {
|
||||||
|
LogErrorWarning(err)
|
||||||
|
return []byte("Error while connecting to database")
|
||||||
|
}
|
||||||
|
defer conn.Close()
|
||||||
|
|
||||||
|
qdata, err := conn.Query(queryStr)
|
||||||
|
LogErrorWarning(err)
|
||||||
|
defer qdata.Close()
|
||||||
|
|
||||||
|
kvp := make(map[string]string)
|
||||||
|
|
||||||
|
for qdata.Next() {
|
||||||
|
var key string
|
||||||
|
var value string
|
||||||
|
|
||||||
|
err = qdata.Scan(&key, &value)
|
||||||
|
LogErrorWarning(err)
|
||||||
|
kvp[key] = value
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonData, err := json.Marshal(kvp)
|
||||||
|
if err != nil {
|
||||||
|
return []byte("Error while generating json")
|
||||||
|
}
|
||||||
|
return jsonData
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
# Nginx API
|
||||||
|
## Listen IP
|
||||||
|
{%- if api.ip is defined %}
|
||||||
|
NGINX_API_LISTEN_IP={{ api.ip }}
|
||||||
|
{%- else %}
|
||||||
|
NGINX_API_LISTEN_IP=localhost
|
||||||
|
{%- endif %}
|
||||||
|
## Listen Port
|
||||||
|
{%- if api.port is defined %}
|
||||||
|
NGINX_API_LISTEN_PORT={{ api.port }}
|
||||||
|
{%- else %}
|
||||||
|
NGINX_API_LISTEN_PORT=79
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
# Database
|
||||||
|
## Database Host
|
||||||
|
{%- if db.host is defined %}
|
||||||
|
DB_HOST={{ db.host }}
|
||||||
|
{%- else %}
|
||||||
|
DB_HOST=localhost
|
||||||
|
{%- endif %}
|
||||||
|
## Database Port
|
||||||
|
{%- if db.port is defined %}
|
||||||
|
DB_PORT={{ db.port }}
|
||||||
|
{%- else %}
|
||||||
|
DB_PORT=3306
|
||||||
|
{%- endif %}
|
||||||
|
## Database User
|
||||||
|
{%- if db.user is defined %}
|
||||||
|
DB_USER={{ db.user }}
|
||||||
|
{%- else %}
|
||||||
|
DB_USER={{0/0}} # Throw error if not set / can be overwritten by envrionment variable
|
||||||
|
{%- endif %}
|
||||||
|
## Database Password
|
||||||
|
{%- if db.user_pw is defined %}
|
||||||
|
DB_USERPW={{ db.user_pw }}
|
||||||
|
{%- else %}
|
||||||
|
DB_USERPW={{0/0}} # Throw error if not set / can be overwritten by envrionment variable
|
||||||
|
{%- endif %}
|
||||||
@@ -14,9 +14,12 @@ echo "Executing Clean tasks"
|
|||||||
rm -rf src/docker-compose.yml || CLEAN_ERROR_ID=1
|
rm -rf src/docker-compose.yml || CLEAN_ERROR_ID=1
|
||||||
|
|
||||||
## Clean DB-Data
|
## Clean DB-Data
|
||||||
rm -rf {% if db.data_path_mysql is defined %}{{ data_path_mysql }}{% else %}./src/db/cache/mysql_data{% endif %} || CLEAN_ERROR_ID=3
|
sudo rm -rf {% if db.data_path_mysql is defined %}{{ data_path_mysql }}{% else %}./src/db/cache/mysql_data{% endif %} || CLEAN_ERROR_ID=3
|
||||||
rm -rf {% if db.data_path_mysql_backup is defined %}{{ data_path_mysql_backup }}{% else %}./src/db/cache/mysql_backup{% endif %} || CLEAN_ERROR_ID=4
|
rm -rf {% if db.data_path_mysql_backup is defined %}{{ data_path_mysql_backup }}{% else %}./src/db/cache/mysql_backup{% endif %} || CLEAN_ERROR_ID=4
|
||||||
|
|
||||||
|
## Remove everything in binary directory
|
||||||
|
rm -rf bin/* || CLEAN_ERROR_ID=5
|
||||||
|
rm -rf bin/.env || CLEAN_ERROR_ID=6
|
||||||
# Post Task
|
# Post Task
|
||||||
## Remove Clean script itself
|
## Remove Clean script itself
|
||||||
rm -rf src/clean-data.sh || CLEAN_ERROR_ID=2
|
rm -rf src/clean-data.sh || CLEAN_ERROR_ID=2
|
||||||
|
|||||||
Reference in New Issue
Block a user