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

Reilly Chase
Nov 13, 2018 · 2 min read


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 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



Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store