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}"
# 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)
end

View File

@ -24,5 +24,8 @@ echo "192.168.0.98" | faaso secret -a busqueda dbhost
faaso build historico
faaso scale historico 0
faaso scale historico 1
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}"
# 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)
end

View File

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

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