Portado tapas

This commit is contained in:
Roberto Alsina 2024-08-21 17:54:09 -03:00
parent d57a58b45a
commit 1e5f913c70
8 changed files with 39 additions and 7 deletions

View File

@ -12,7 +12,7 @@ DBURL = "postgres://#{USER}:#{PASS}@#{DBHOST}:5432/nombres"
puts "Connnecting to #{DBURL}" puts "Connnecting to #{DBURL}"
# Create a connection pool to the database # Create a connection pool to the database
pg = ConnectionPool.new(capacity: 5, timeout: 1.seconds) do pg = ConnectionPool.new(capacity: 25, timeout: 1.seconds) do
PG.connect(DBURL) PG.connect(DBURL)
end end

View File

@ -24,5 +24,8 @@ echo "192.168.0.98" | faaso secret -a busqueda dbhost
faaso build historico faaso build historico
faaso scale historico 0 faaso scale historico 0
faaso scale historico 1 faaso scale historico 1
rsync -rav nombres.ralsina.me/* ralsina@pinky:/data/websites/nombres.ralsina.me/ rsync -rav nombres.ralsina.me/* ralsina@pinky:/data/websites/nombres.ralsina.me/
faaso build tapas
faaso scale tapas 0
faaso scale tapas 1

View File

@ -12,7 +12,7 @@ DBURL = "postgres://#{USER}:#{PASS}@#{DBHOST}:5432/nombres"
puts "Connnecting to #{DBURL}" puts "Connnecting to #{DBURL}"
# Create a connection pool to the database # Create a connection pool to the database
pg = ConnectionPool.new(capacity: 5, timeout: 1.seconds) do pg = ConnectionPool.new(capacity: 25, timeout: 1.seconds) do
PG.connect(DBURL) PG.connect(DBURL)
end end

View File

@ -1,10 +1,12 @@
from json import loads from flask import Flask, request
from tapita import Cover from tapita import Cover
from io import BytesIO from io import BytesIO
import base64 import base64
app = Flask("tapas")
def handle(req): @app.route('/', methods=['POST'])
def handle():
"""handle a request to the function """handle a request to the function
Args: Args:
req (str): request body req (str): request body
@ -15,10 +17,10 @@ def handle(req):
"author": "bat", "author": "bat",
} }
""" """
if not req: if not request:
return "Foo", 200, {"Content-Type": "text/plain"} return "Foo", 200, {"Content-Type": "text/plain"}
try: try:
args = loads(req) args = request.json
except Exception: except Exception:
return "Bad Request", 400 return "Bad Request", 400
@ -31,3 +33,9 @@ def handle(req):
200, 200,
{"Content-Type": "text/html"}, {"Content-Type": "text/html"},
) )
@app.route('/ping')
def ping():
return "OK"

18
tapas/funko.yml Normal file
View File

@ -0,0 +1,18 @@
name: tapas
runtime: flask
options:
ship_packages:
- jpeg
- zlib
- freetype
devel_packages:
- zlib-dev
- jpeg-dev
- freetype-dev
healthcheck_options: "--interval=1m --timeout=2s --start-period=2s --retries=3"
healthcheck_command: "curl --fail http://localhost:3000/ping || exit 1"
copy_from_build:
- "static static"
- "venv venv"
- "run.sh ."
- "funko.py ."

View File

@ -1 +1,2 @@
flask
tapita tapita

2
tapas/run.sh Normal file
View File

@ -0,0 +1,2 @@
#!/bin/sh
uwsgi --plugins http,python -H venv --http 0.0.0.0:3000 --master -p 1 -w funko:app