Skip to content

oskarissimus/pythocron

Repository files navigation

Python + Cron = Pythocron

Purpose of this project is to enable simple scheduled code execution. It's like cloud functions + scheduler with jupyter-notebook-like interface and user-friendliness.

Deploy

Run on Google Cloud

Running

docker run -p 8080:2137 oskarissimus/pythocron

Building docker images from repo

# Cloning repo
git clone https://github.com/oskarissimus/pythocron.git
cd pythocron

# Docker build and run
docker build -t pythocron -f default.Dockerfile .
docker run -p 8000:2137 pythocron

Than go to http://localhost:8000

You can also use backend directly http://localhost:8000/api/v1/docs

Running dev

backend

# please use virtual envs for own sanity
cd backend
mkvirtualenv pythocron
pip install -r requrements.txt
poetry isntall
poetry run uvicorn pythocron.main:app --host=0.0.0.0 --reload
# project uses crontab as root, so have that in mind while running dev

frontend

cd frontend
# Installing frontend dependencies
npm install

# Running frontend in dev mode
npm start

To stop, just exit npm start with ctrl-c

General architecture

Backend

Backend is written in Python 3.8 + Fastapi. Poetry is responsible for dependency management. Python-crontab provides python interface for cron management.

Backend is wrapped in docker image. It is based on python:3.8-slim-buster. Tini is utilized to solve problems with running two services in container (cron and uvicorn for fastapi)

After starting backend there are auto-generated interactive docs on localhost:8000/docs

Fastapi auto-generated interactive docs

Frontend

Frontend is made in React js.

Main page

Contributing

Feel free to fork, create pull requests, and submit issues. This project is just starting, so there are a lot of bugs. If You find one, please create an issue, I will try to fix it!

Todo list

  • Create route /{pythocron_id} in frontend to show particular pythocron
  • Display list of uploaded pythocrons
  • Handle deleting pythocrons
  • docker-compose
  • Responsive design
  • Handle updating pythocrons
  • Publish to docker hub
  • Configure github actions to automathically build and push to docker hub
  • Unit testing for backend
  • Handle deactivating pythocrons
  • Configure github actions to run tests

Demo

google cloud run - work as long as there is opened browser window - https://pythocron-c6bwyemtwq-lm.a.run.app/

heroku - restarts every 24h - https://pythocron.herokuapp.com/

Known issues

  1. Deploy to gcp vm
Error restarting service: Failed to try-restart nscd.service: Unit nscd.service not found.
Error restarting service: Failed to try-restart unscd.service: Unit unscd.service not found.
Error restarting service: Failed to try-restart cron.service: Unit cron.service not found.
Error restarting service: Failed to try-restart crond.service: Unit crond.service not found.
Error reloading service: Failed to reload-or-restart ssh.service: Unit ssh.service not found.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors