start / stop docker container on table start / stop
This commit is contained in:
12
src/main.py
12
src/main.py
@@ -2,6 +2,7 @@ from flask import Flask, g, jsonify, request
|
||||
import sqlite3
|
||||
import game_tables
|
||||
import key_tables
|
||||
import container_managment
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@@ -82,8 +83,12 @@ def activate_table(table_id):
|
||||
|
||||
keys[0].reserve(table.game_table_id)
|
||||
table.active = True
|
||||
table.docker_id = container_managment.start_container(
|
||||
table.game_table_name, "test_table_1"
|
||||
)
|
||||
app.logger.info(table.docker_id)
|
||||
keys[0].commit(cursor)
|
||||
table.commit(cursor)
|
||||
table.commit(app, cursor)
|
||||
cursor.close()
|
||||
db.commit()
|
||||
return jsonify(table.toJson())
|
||||
@@ -105,7 +110,10 @@ def deactivate_table(table_id):
|
||||
key.release()
|
||||
key.commit(cursor)
|
||||
|
||||
table.commit(cursor)
|
||||
table.commit(app, cursor)
|
||||
app.logger.info(table.docker_id)
|
||||
container_managment.stop_container(table.docker_id)
|
||||
|
||||
cursor.close()
|
||||
db.commit()
|
||||
return jsonify(table.toJson())
|
||||
|
||||
Reference in New Issue
Block a user