GhostiFi — Triggering server create, rebuild, or destroy based on subscription status

Overview

In this post I am sharing how I’ve integrated a WordPress SaaS subscription frontend with my Python backend for GhostiFi, a VPS VPN service that I am building. I query the database from Python once every minute on a cron and then compare the server table and wp_edd_subscriptions table in order to determine when to trigger a server create, rebuild, or destroy function/method.

This is part 4 of a series of posts that I am writing about developing my second SaaS business. I launched my first SaaS, a UniFi hosting platform, in May of this year and now have over 100 paying customers on that service.

In part 2, I wrote a step-by-step pseudo code overview of how the entire application would work. In this post, I share the actual code for this section of it:

Here is what that looks like in Python:

This is a much better approach than how I wrote HostiFi’s code because I made some fancier SQL statements with joins. Last time I wrote 2 different queries for each (one for subscriptions, one for servers) and looped over them, which was inefficient but worked the same.

Closing thoughts

I hope this was helpful for anyone who is an aspiring programmer or entrepreneur to be able to follow along from my initial sketched design of a user interface for my product idea, to pseudo code, and finally actual code.

If you have any feedback on how I could improve this, please let me know in the comments section!

I am also looking for feedback on the concept itself, as well as beta testers. Please sign up for the newsletter at https://ghostifi.net if you are interested.

If you want to know when I release another post about building GhostiFi, you can follow me on Twitter: @_rchase_ or Medium: Reilly Chase