dotmethod

Originally posted on dotmethod.me

cover

Here’s a simple, self-hosted configuration for Plausible Analytics, meant for deploying to Kubernetes.

Note: All the code and instructions have been uploaded to github: https://github.com/dotmethodme/plausible-kubernetes

How to

  1. Go to https://github.com/dotmethodme/plausible-kubernetes and clone the repository. All yaml files are inside the folder named base
  2. Open postgress.yaml. Edit the POSTGRES_PASSWORD field and set a randomly generated password for the postgres database
  3. Open ingress.yaml. Insert your chosen domain name into the host fields
  4. Open secret.yaml. Configure the marked fields.
  5. Apply the configuration with kubectl apply -f ./base

Read more:

--

--

Originally posted on dotmethod.me

The decorator method

def fire_and_forget(f):
from functools import wraps

@wraps(f)
def wrapped(*args, **kwargs):
loop = asyncio.get_event_loop()
if callable(f):
return loop.run_in_executor(None, f, *args, **kwargs)
else:
raise TypeError('Task must be a callable')
return wrapped

An example:

Use the method above as a decorator for other methods:

@fire_and_forget
async hello_world():
sleep(5)
print("Successful")

--

--