Check out this link on Github. It's a python script that listen for connections and when a player connects it launches the Minecraft server. If there are no players it just stops the Minecraft server.
(It's made for Minecraft vanilla but it's so easy to configure also for other types of Minecraft servers (just follow the guide))
And it's updated to 2019 if someone needs it!
i created this myself and would be happy if you used this!