How do I prevent my GPS-tracking app from stopping? I'm running a very simple open-source Android GPS tracker: 

https://github.com/herverenault/Self-Hosted-GPS-Tracker

I have it set to post GPS coordinates from my phone to my server every 30 seconds.  The problem is: it sometimes works, and sometimes sleeps for 3 minutes, or 8 minutes, or sometimes seems like it is completely stopped.

What might be causing this and is there anyway to prevent it from happening? 

This is not a "secret" app or malicious in anyway; the person running it knows they are running it.  I just don't want to make the user re-launch the app every 5 minutes, or even whenever they restart their device (which the code says it supports already).
The Android OS intentionally tries to prevent applications like this from running to prevent battery drain. For Android 6 specifically, you need to know about the doze and app standby features. Doze prevents applications from running when the device is not in use. App standby defers network activity for seldom-used applications. Both of these are likely affecting your usage. 

Running GPS (actual GPS, not just location services), is a huge power drain. 

If you don't care about power, you can try: 


Keep device on with your application in foreground. 
Whitelist your application for doze and app standby (see above link).