Heroku Startup

by fourjr

GitHub Readme.md

Heroku Startup

This application functions as a web dyno off heroku and allows heroku applications to function throughout the month without a credit card.

This is targeted at worker dynos although other dyno types should work as well.

This repository is licensed under the MIT License. Read the disclaimer

Abbreviations

In this documentation, we will call the heroku-startup (based on this repository) application "server" and the application that you are trying to keep alive "client".

Client Setup

In this example, we will take our client app name as chatbot.

  1. Create 2 Heroku accounts
    • I used Yandex as it was an email service without phone verification that Heroku did not block.
    • When you play with multiple accounts, you can add a "main" account as a Heroku Collabrator to allow for easy management.
  2. In each of the accounts, create an application called chatbot-1 and chatbot-2
  3. Create an environment variable for both apps as HEROKU_APP_NAME with the value of chatbot-1 and chatbot-2 respectively.
  4. Send a GET request to https://serverurl/login/{HEROKU_APP_NAME} upon startup before doing anything else.
  5. When your application is about to exit, send a GET request to https://serverurl/logout/{HEROKU_APP_NAME}

Sending Requests

Python sample code:

import requests
import os

requests.get(f"https://serverurl/login/{os.getenv('HEROKU_APP_NAME')}/")
main()
requests.get(f"https://serverurl/logout/{os.getenv('HEROKU_APP_NAME')}/")

Server Setup

  1. Create another Heroku account

    • I used Yandex as it was an email service without phone verification that Heroku did not block.
    • When you play with multiple accounts, you can add a "main" account as a Heroku Collabrator to allow for easy management.
  2. Click this big purple button Deploy to Heroku

  3. Retrieve your Heroku API token from https://dashboard.heroku.com/account (scroll down)

  4. Deploy the web dyno

How this works

When your first application has run out of dyno hours and crashes, the server would realise that it is not logging back in (after a 1 minute timeout -- can be changed with a timeout config variable) and start the second application.

Once the first application starts back up, the second will be stopped.
The first application can start up due to a variety of reasons:

  • A new month, dyno hours reset
  • App takes unusually long to start.

The script uses the Heroku Platform API to control the dynos.

Disclaimer

I do not hold any responsibility if you get banned from Heroku. Choosing to add this to your Heroku experience is completely your own decision and I have no part to play in that. This is simply a tool for risk-takers who wish to risk that their account might be deleted to have fun.