Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hexiro/herokron

Easily switch Heroku apps on/off from CLI. Supports multiple accounts.
https://github.com/hexiro/herokron

cron heroku python python3

Last synced: 25 days ago
JSON representation

Easily switch Heroku apps on/off from CLI. Supports multiple accounts.

Awesome Lists containing this project

README

        

## Herokron

Herokron is a python package used to make switching [Heroku](https://heroku.com/) apps on/off easy, especially between accounts. The primary use case is from the command line in the form of a cron job (hence the ending *kron*), but Herokron does work in a python file.

![Forks](https://img.shields.io/github/forks/Hexiro/Herokron)
![Stars](https://img.shields.io/github/stars/Hexiro/Herokron)
![Issues](https://img.shields.io/github/issues/Hexiro/Herokron)
![License](https://img.shields.io/github/license/Hexiro/Herokron)

## 📦 Installation

Install the package with pip.

```
pip3 install git+https://github.com/Hexiro/herokron
```

## 💾 Setup

Load API keys, and setup logging
```console
$ herokron --add-key {key}
$ herokron --set-webhook {discord_webhook}
$ herokron --set-color {discord_embed_color}
```
View the database to make sure everything is working.
```console
$ herokron -database
```

## 🖥️ Usage

### Command Line

```console
$ herokron --help
```
app commands (classified by leading -)
```console
-on ON Calls the `on` function to turn an app on.
-off OFF Calls the `off` function to turn an app off.
-status STATUS Calls the `status` function view the current status of an app.
```
database commands (classified by leading --)
```
--database [DATABASE] Prints the formatted database.
--add-key ADD_KEY Adds the Heroku API key specified.
--remove-key REMOVE_KEY Removes the Heroku API key specified.
--set-webhook SET_WEBHOOK Sets the Discord Webhook URL for logging.
--set-color SET_COLOR Sets the Discord Embed Color.
--no-log [NO_LOG] Stops this iteration from logging.
--no-print [NO_PRINT] Stops this iteration from printing.
```

### Python

app commands
```py
import herokron
herokron.on("herokron-example")
herokron.off("herokron-example")
herokron.status("herokron-example")
```

while they function correctly, it's not exactly practical because the database is still loaded from the database file so that has to be set before hand.

# ⌛ Cron
The following example will start a Heroku app everyday at 8 am.

### crontab
```
0 8 * * * herokron -on [app]
```

If this isn't working, cron is most likely just having issues finding Herokron. If this happens, you will need to specify the Herokron path.

### command line
```
$ which herokron
/home/pi/.local/bin/herokron
```
### crontab
```
0 8 * * * /home/pi/.local/bin/herokron -on [app]
```

# Contributing
Pull requests are always 100% welcomed and appreciated. Right now, I have no way of testing Mac OS and other Linux distributions. All modern operating systems should work, as they're only used to find the local database file.