mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-04 21:20:35 +00:00
docker: add container websocket in docker-compose
This commit is contained in:
14
WebSocketServer/Dockerfile
Normal file
14
WebSocketServer/Dockerfile
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
FROM python:3.12-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt-get update && apt-get install -y git && apt-get clean
|
||||
|
||||
RUN git clone https://github.com/welton89/websocket-RRBEC.git /app
|
||||
|
||||
RUN pip install --upgrade pip && pip install websockets
|
||||
|
||||
EXPOSE 8765
|
||||
|
||||
CMD ["python", "websocket_server.py"]
|
||||
@@ -55,6 +55,16 @@ services:
|
||||
networks:
|
||||
- app_network
|
||||
|
||||
websocket_server:
|
||||
build:
|
||||
context: ./WebSocketServer
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "8765:8765"
|
||||
restart: on-failure
|
||||
networks:
|
||||
- app_network
|
||||
|
||||
volumes:
|
||||
static_volume:
|
||||
db_data:
|
||||
|
||||
@@ -15,17 +15,15 @@ import websockets
|
||||
|
||||
async def enviar_mensagem(msg):
|
||||
try:
|
||||
uri = "ws://192.168.1.150:8765"
|
||||
uri = "ws://websocket_server:8765"
|
||||
async with websockets.connect(uri) as websocket:
|
||||
await websocket.send(msg)
|
||||
print(f"> Enviado: {msg}")
|
||||
# print(f"> Enviado: {msg}")
|
||||
|
||||
resposta = await websocket.recv()
|
||||
print(f"< Recebido: {resposta}")
|
||||
# resposta = await websocket.recv()
|
||||
# print(f"< Recebido: {resposta}")
|
||||
except Exception as e:
|
||||
print(f"Erro ao enviar mensagem: {e}")
|
||||
|
||||
|
||||
print(f"Erro ao enviar mensagem via websocket: {e}")
|
||||
|
||||
|
||||
def somar(consumo:ProductComanda, comanda:Comanda):
|
||||
@@ -87,7 +85,7 @@ def addProduct(request, product_id, comanda_id):
|
||||
'speak': f'Novo pedido! {product.name}, para {comanda.name}.'
|
||||
})
|
||||
|
||||
# asyncio.run(enviar_mensagem(msg))
|
||||
asyncio.run(enviar_mensagem(msg))
|
||||
consumo = ProductComanda.objects.filter(comanda=comanda_id)
|
||||
valores = somar(consumo,comanda)
|
||||
|
||||
|
||||
@@ -98,7 +98,6 @@ def addContaCliente(request):
|
||||
clientId = int(request.POST.get('select-client'))
|
||||
comanda = Comanda.objects.get(id=comandaId)
|
||||
client = Client.objects.get(id=clientId)
|
||||
# client.debt = Decimal(0)
|
||||
comanda.client = client
|
||||
comanda.dt_close = timezone.now()
|
||||
comanda.status = 'FIADO'
|
||||
|
||||
@@ -17,13 +17,13 @@ RRB&C - DashBoard
|
||||
<input id="data-start" name="data-start" oninput="mediaCuisine()" type="date">
|
||||
<input id="data-end" name="data-end" oninput="mediaCuisine()" type="date">
|
||||
</div>
|
||||
<h4 id="30-days">Últimos 30 diAs</h4>
|
||||
<h4 id="30-days">Últimos 30 dias</h4>
|
||||
</div>
|
||||
|
||||
<div class="grid-container">
|
||||
<div class="card-resumo">
|
||||
<div>
|
||||
<p> Faturament0 </p>
|
||||
<p> Faturamento </p>
|
||||
<h2 id="total-pagamentos">Carregando... </h2>
|
||||
</div>
|
||||
<img src="{% static 'midia/icons/money-bag.svg' %}" >
|
||||
|
||||
@@ -19,11 +19,6 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function verificarCookieNotificacao() {
|
||||
var iconNotify = document.getElementById('icon-notify');
|
||||
if (document.cookie.indexOf('notificacao=') === -1) {
|
||||
@@ -56,7 +51,7 @@ function cookieNotificacao() {
|
||||
}
|
||||
}
|
||||
|
||||
const websocket = new WebSocket('ws://192.168.1.150:8765');
|
||||
const websocket = new WebSocket('ws://0.0.0.0:8765');
|
||||
const nomeUsuario = document.getElementById('user-info').textContent;
|
||||
|
||||
websocket.addEventListener('open', (event) => {
|
||||
|
||||
Reference in New Issue
Block a user