A Node.js HTTP proxy that tracks managed PaaS account applications and auto-stop&start them

Overview

paastis-engine

Features

Paastis engine is the heart of the Paastis project.

Its goal is to monitor and manage (start & stop) PaaS applications based on their activity.

Paastis schema

Scenario :

  • Paastis detects that there is a new review app on Scalingo ; it begins to monitor it
  • If the app is not accessed during the next 15mn (editable duration), then it is shut down (but not delete)
  • If someone wants to finally access the app, then it is awakened
  • Thus, the engine proxies the HTTP request to the upstream desired location

It is composed of the following building blocks :

  • a proxy that forwards ingoing HTTP requests to an upstream server (based on the predefined PaaS provider)
  • a registry of the running PaaS applications to monitor (in-memory or Redis-based)
  • a cron process that regularly (every minute by default) update the registry with new / deleted / running / sleeping PaaS applications

Paastis engine supports multiple PaaS providers (but not yet all their regions) :

  • Clever Cloud
  • Heroku
  • Scalingo

It is also possible to define Shell commands (a.k.a. hooks) to be executed for each application on the following phases :

  • before an app to be stopped
  • after it stopped
  • before an app to be started
  • after it started

Sometimes, we do not want to monitor and manage some apps (for example, an instance of Paastis engine 😙 ). We can exclude / ignore apps to me managed (with environment variable REGISTRY_IGNORED_APPS.

Installation

# 1/ Fetch sources
git clone [email protected]:paastis/paastis-engine.git

# 2/ Enter project directory
cd paastis-engine

# 3/ Generate and edit .env file (especially, define SCALINGO_API_TOKEN value with your own API key)
cp env.sample .env

# 4/ Install project dependencies
npm install

# 5/ Start project
npm start

# 6/ Enjoy
curl -v http://localhost:3000 -H Host:my-cloud-app.proxy.example.com

Configuration

Variable Required Type Format Default
HOST false String IP or name 0.0.0.0
PORT false Number Number 3000
REGISTRY_TYPE false String "in-memory" or "redis" in-memory
REGISTRY_IGNORED_APPS false String List of strings, separated by a comma -
REDIS_URL false String redis://: -
START_AND_STOP_CHECKING_INTERVAL_CRON false String CRON expression * * * * *
START_AND_STOP_MAX_IDLE_TIME false Number Number of minutes 51
PROVIDER_NAME true String "scalingo" or "clever-cloud" -
PROVIDER_SCALINGO_API_TOKEN only if PROVIDER_NAME is "scalingo" String Token string -
PROVIDER_SCALINGO_OPERATION_TIMEOUT false Number Number of seconds -
PROVIDER_CLEVER_API_HOST false String URL https://api.clever-cloud.com
PROVIDER_CLEVER_OAUTH_CONSUMER_KEY only if PROVIDER_NAME is "clever-cloud" String Token string -
PROVIDER_CLEVER_OAUTH_CONSUMER_SECRET only if PROVIDER_NAME is "clever-cloud" String Token string -
PROVIDER_CLEVER_TOKEN only if PROVIDER_NAME is "clever-cloud" String Token string -
PROVIDER_CLEVER_SECRET only if PROVIDER_NAME is "clever-cloud" String Token string -
PROVIDER_CLEVER_OPERATION_TIMEOUT false Number Number of seconds 60
HOOKS_BEFORE_START false String Shell command(s) -
HOOKS_AFTER_START false String Shell command(s) -
HOOKS_BEFORE_STOP false String Shell command(s) -
HOOKS_AFTER_STOP false String Shell command(s) -
ROUTING_SYSTEM_API_ENABLED false Boolean false
ROUTING_SYSTEM_API_TOKEN false String xxx-yyy-zzz -
Comments
  • Add continuous integration

    Add continuous integration

    What we see / have

    There is no automation controls on the pushed code (lint, test, coverage, dependency checks, vulnerability checks, etc).

    What we intent / want

    Some mechanism that prevents future commits to break the build / code / project and help contributions.

    opened by jbuget 1
  • ci: Add Continuous Integration

    ci: Add Continuous Integration

    🍣 Context / problem There is no Continuous Integration yet. It is a software development good practice.

    🎯 Idea / solution Using GitHub Actions (with CodeQL integration) to automatically run testing, linting, scanning, vulnerability checking, etc.

    💡 Discussion / consequences Each time a commit is pushed on a branch, then some automated checks are executed.

    🤖 Tests / checks Check that GitHub Checks are displayed and executed

    opened by flemzord 1
  • Add deployment scripts

    Add deployment scripts

    :wrench: Problem

    Describe here the intention of this Pull Request, focusing on the needs and intentions.

    :cake: Solution

    Describe here the chosen solution and how it has been put in place. What were the road blockers ?.

    :rotating_light: Points of interest

    If any, details what are the edge cases, or any additional topics to share about.

    :desert_island: How to test

    Describe here how to reproduce the orginal bug, the data used to test the new application behavior, etc.

    close #18

    opened by jbuget 0
  • chore: configure npm module packaging

    chore: configure npm module packaging

    :wrench: Problem

    It is time to publish a beta-prod-ready version of the app.

    :cake: Solution

    1. Create a release in GitHub → it creates a tag
    2. Use a GitHub Action to push the tag on npmjs registry

    :rotating_light: Points of interest

    Links:

    • https://snyk.io/blog/best-practices-create-modern-npm-package/
    • https://docs.npmjs.com/cli/v8/using-npm/scripts
    • https://cmdcolin.github.io/posts/2021-12-31-npm-package
    • https://docs.npmjs.com/cli/v9/configuring-npm/package-json#files

    :desert_island: How to test

    Describe here how to reproduce the orginal bug, the data used to test the new application behavior, etc.

    opened by jbuget 0
  • feat: add CLI

    feat: add CLI

    :wrench: Problem

    Paastis can be run as a webapp.

    In order to improve Developer eXperience (DX), we want to be able to simply run a Paastis instance with a one-line shell command, thanks to npx :

    $ paastis -H localhost -P 3000 --max-idle-time 5
    

    :cake: Solution

    Using yargs.

    :rotating_light: Points of interest

    Current supported options are :

    • -H, --host <string> [default: "0.0.0.0"]
    • -P, --port <number> [default: 3000]
    • --max-idle-time <number> [default: 15]

    :desert_island: How to test

    On localhost :

    $ npm link
    $ PROVIDER_NAME=scalingo PROVIDER_SCALINGO_API_TOKEN=tk-us-xxx paastis -H localhost -P 333 --max-idle-time 1
    

    fix #9

    opened by jbuget 0
  • chore: Add code formatting

    chore: Add code formatting

    :wrench: Problem

    There is no formatting rules clearly defined. It makes it hard to contribute. Some code changes can be avoid, making code review easier.

    :cake: Solution

    Add Prettier and .editorconfig file.

    Add 2 npm dev tasks :

    • format:check
    • format:write

    Include format:check to CI "Test" job.

    :rotating_light: Points of interest

    If any, details what are the edge cases, or any additional topics to share about.

    :desert_island: How to test

    Check that the 2 formatting tasks work. Check that checks are taken into account by GHA.

    based on #4 from @flemzord (thanks ❤️ ❤️ ❤️)

    opened by jbuget 0
  • ci: fix

    ci: fix

    :wrench: Problem

    Works on localhost but fails on GitHub Actions CI.

    :cake: Solution

    Problem was that a override START_AND_STOP_MAX_IDLE_TIME in my own .env file and then I adapted the tests according to this config.

    :rotating_light: Points of interest

    This PR also contains a little BSR that clean import.

    :desert_island: How to test

    GHA checks are ok.

    opened by jbuget 0
  • chore: Create LICENSE

    chore: Create LICENSE

    :wrench: Problem

    There is no licence defined yet.

    It makes choosing, using and contributing to this this tool.

    :cake: Solution

    Define a licence. Make it clear.

    :rotating_light: Points of interest

    We want a FOSS license. We choose AGPL-3.0 (GNU Affero GPL).

    :desert_island: How to test

    There is a LICENSE file in the sources.

    GitHub highlight the licence of the repository.

    🔗 Links

    fix #7

    opened by jbuget 0
  • chore: Add pull request template.

    chore: Add pull request template.

    :wrench: Problem

    Some contributions are made without any clear intention nor context, making it hard to understand why the changes are suggested.

    :cake: Solution

    Add a pull request template file and take advantage of GitHub template feature to offer a clear template to new contributions.

    :rotating_light: Points of interest

    None

    :desert_island: How to test

    Create a pull request and check that the pull request body is prefilled with content of .github/pull_request_templated.md file.

    closes #6

    opened by HEYGUL 0
  • Make the project usable as a node.js CLI

    Make the project usable as a node.js CLI

    What we see / have

    Today, the only way to use Paastis module is to fork the project and to make it running as a webapp.

    What we intent / want

    It would be a lot better for developer experience to be able to simply execute something like : npx paastis

    opened by jbuget 0
  • Add FOSS licence (AGPL-3.0)

    Add FOSS licence (AGPL-3.0)

    What we see / have

    No licence is defined yet in the repository.

    If a repository has no license, then all rights are reserved and it is not Open Source or Free. You cannot modify or redistribute this code without explicit permission from the copyright holder. src: StackExchange

    What we intent / want

    Add a licence to make explicit that Paastis library is a FOSS project.

    I propose AGPL-3.0.

    opened by jbuget 0
  • Add TypeScript

    Add TypeScript

    What problems can TypeScript solve ?

    src: https://www.typescriptlang.org/why-create-typescript

    Typically, the need to ensure there are no bugs in your code can be handled by writing automated tests, then by manually verifying that the code works as you expect and finally having another person validate that it seems correct.

    Not many companies are the size of Microsoft, however a lot of all problems writing JavaScript in large codebases are the same. Many JavaScript apps are made up of hundreds of thousands of files. A single change to one individual file can affect the behaviour of any number of other files, like throwing a pebble into a pond and causing ripples to spread out to the bank.

    Validating the connections between every part of your project can get time consuming quickly, using a type-checked language like TypeScript can handle that automatically and provide instant feedback during development.

    These features allows TypeScript to help developers feel more confident in their code, and save considerable amounts time in validating that they have not accidentally broken the project.

    Advantages of using TypeScript

    src: https://www.contentful.com/blog/2022/08/18/what-is-typescript-and-why-should-you-use-it/

    TypeScript extends JavaScript, providing a better developer experience. The benefits of using TypeScript over JavaScript include:

    • Static typing – TypeScript comes with optional static typing and a type inference system, which means that a variable, declared with no type may be inferred by TypeScript based on its value.

    • Object oriented programming – TypeScript supports object-oriented programming concepts like classes, inheritance, etc.

    • Compile time checks – JavaScript is an interpreted programming language. There is no compilation involved. Hence, the errors get caught during the runtime. Since TypeScript compiles into JavaScript, errors get reported during the compile time rather than the runtime.

    • Code editor support – IDEs or code editors like VS Code support autocomplete for a TypeScript codebase. They also provide inline documentation and highlight the errors.

    • Use existing packages – You might want to use an npm package that is written in JavaScript. Since TypeScript is a superset of JavaScript, you can import and use that package. Moreover, the TypeScript community creates and maintains type definitions for popular packages that can be utilized in your project. You can learn more about it here.

    opened by jbuget 0
Releases(v0.1.0)
  • v0.1.0(Nov 5, 2022)

    This is the first officially usable version of Paastis.

    Features

    • auto stop & start of PaaS apps according to their idle time
    • support for multiple PaaS providers: Heroku, Scalingo and Clever Cloud
    • suport of .env file
    • support of advanced paastis.yml rules file
    • support of group of apps customization, based on regular rexpressions
    • support of ignored apps
    • support of 2 types of running apps registry: in-memory or Redis
    • possibility to define scheduler delay and apps max-idle-time
    • documentation
    Source code(tar.gz)
    Source code(zip)
Owner
null
A simple to do list webpage where you can log the daily tasks you have to do, mark them as checked, modify them, reorder them and remove them. Made using HTML, CSS and JavaScript.

To-Do-List This Webpage is for an app called To-Do-List which helps you add, remove or check tasks you have to do. It is a simple web page which conta

Zeeshan Haider 9 Mar 12, 2022
Make friends through music. Discover great sound tracks on Solana and play them with your buddies :dancer:.

Acoustic Licious COVID-19 has significantly impacted the mental health of children and adults alike. Globally, the population suffering from lonelines

Devyansh Chawla 4 Oct 28, 2022
🦆 The repository for dealing with all the ducks created and managed by the Fairfield Programming Association.

Download Since the Fairfield Programming Association's duck generator is built on top of node.js and npm, you need to have both of those installed as

Fairfield Programming Association 15 Feb 4, 2022
proxy 🦄 yxorp is your Web Proxy as a Service (SAAS) Multi-tenant, Multi-Threaded, with Cache & Article Spinner

proxy ?? yxorp is your Web Proxy as a Service (SAAS) Multi-tenant, Multi-Threaded, with Cache & Article Spinner. Batteries are included, Content Spinning and Caching Engine, all housed within a stunning web GUI. A unique high-performance, plug-and-play, multi-threaded website mirror and article spinner

4D/ҵ.com Dashboards 13 Dec 30, 2022
Proxy but misspelled -- closed proxy for the internet

pyrox Proxy that runs on Cloudflare Workers. Setup Install wrangler2. npm install wrangler. Generate a public Ed25519 key, exported under SPKI mode wi

bots.gg 10 Sep 9, 2022
🫥 Copy repository without the git information for self-managed gitlab, very fast.

English | 简体中文 degitlab ?? degitlab -> de-git-lab Copy repository without the git information for self-managed gitlab, very fast. Why? In self-managed

東澔 6 Oct 16, 2022
This is a Webpack based to-do-list project. With this app, users can add thier daily routine tasks to the list, mark them as complet, edit them or delete them.

To Do List This is a Webpack based to-do-list project. With this app, users can add thier daily routine tasks to the list, mark them as complet, edit

Ali Aqa Atayee 12 Oct 30, 2022
a vscode extension for http response data auto transform ts type.

Api2ts 这是一个自动将 http 的响应数据转化为 ts 的类型,使用 json-to-ts 做的。 Features 框选配置项后,使用快捷键 alt+Q : 请求参数配置文件 在根目录下创建 Api2ts.config.json 文件,配置项如下: { "baseURL": "http

phy-lei 6 Jun 30, 2022
This is a single page web application that keeps tracks of books. Book details captured are the book title, author and ISBN. User can add a book, view a list of books and also remove any un wanted books.

Project Name This is a single page web application that keeps tracks of books. Book details captured are the book title, author and ISBN. User can add

Olivier 6 Nov 20, 2022
An IoT bottle that tracks water consumption. Winner of Best Health Hack, MLH's Best Hardware Hack, and QB3's Best Big Data for the Improvement of Health Care Winner at CruzHacks 2022.

An IoT bottle that tracks water consumption. Winner of Best Health Hack, MLH's Best Hardware Hack, and QB3's Best Big Data for the Improvement of Health Care Winner at CruzHacks 2022.

Nathanael Garza 2 Jan 21, 2022
Smart Auto Move learns the size and position of your application windows and restores them to the correct place on subsequent launches. Supports GNOME Wayland.

smart-auto-move smart-auto-move is a Gnome Shell extension which keeps track of all application windows and restores them to the previous position, si

khimaros 40 Dec 23, 2022
📡Usagi-http-interaction: A library for interacting with Http Interaction API

?? - A library for interacting with Http Interaction API (API for receiving interactions.)

Rabbit House Corp 3 Oct 24, 2022
A simple menubar app for GNOME Shell that tracks how long you've been using your computer uninterruptedly

Welcome to Since Indicator ?? ?? Homepage Since Indicator is a simple menubar app for GNOME Shell that tracks how long you've been using your computer

Lorenzo Carbonell 3 Oct 20, 2022
Automatic Role Adder Is Usually Used In Coding Servers Which Give Access To Codes By Subbing To Their Channel So This Helps Them To Auto Role People :)

Automatic Role Adder Setup Guide Automatic Role Adder Is Usually Used In Coding Servers Which Give Access To Codes By Subbing To Their Channel So This

NotJust 25 Dec 23, 2022
🌹 Your one stop place for moderation and more.

Azalea Azalea is a advanced moderation bot used. This repo includes, the discord bot: Moderation, server stats, welcome & leave, reaction roles, auto

Saige 2 Sep 13, 2022
Run a command, watch the filesystem, stop the process on file change and then run the command again...

hubmon Run a command, watch the filesystem, stop the process on file change and then run the command again... Install You can install this command lin

Hubert SABLONNIÈRE 7 Jul 30, 2022
radiQL, your one-stop-shop for migrating from a legacy REST backend to an efficient and modern GraphQL API

Welcome to radiQL, the one-stop solution for setting up GraphQL on a PostgreSQL database. Check out our Medium article here. At A Glance: Give us your

OSLabs Beta 90 Nov 14, 2022
A one-stop app to manage and organize your daily reading habits!

Reading Tracker with Local Authorization This is a place where you can write down all the books you plan to read, are currently reading, have finished

Nathan Folkman 4 Sep 9, 2022
Stop re-writing thirdweb snippets. Use thirdsnips to make it all snap!

?? thirdsnips Stop re-writing thirdweb snippets. Use thirdsnips to make it all snap! Thirdsnips is a tool which enhances the developer experience whil

Avneesh Agarwal 24 Dec 14, 2022