Techmo Posted July 1, 2018 Share Posted July 1, 2018 (edited) This is just something I've been working on to pass the time. I started it this afternoon, and after spending a good amount of time on it, decided to post it here. What this is is a watchdog module written in c++ for garrys mod, but could in theory be written for any source engine game. I wrote this to see if it could be a solution to events where the server crashes, and never restarts. I assume the server has a batch script to restart it in the event the srcds.exe process ends, so this is to help the server out when it locks up, but doesn't completely crash. It keeps a watchdog timer running on a separate thread that has to be reset by the server every tick. When this timer runs out, it does whatever you would like it to do when the server locks up. This could be restarting the server, or even the entire system if desired. Resetting the timer has no impact on server performance. This project also contains a standard library I've been working on for gmod modules in c++. ATM it doesn't do much, but it's a start. I plan to add on to this as I develop. Also, there are a few bugs. The most problematic one being the watchdog thread not releasing the timer values to the server thread. It should be an easy fix, but it's been a long day. The whole thing is on GitHub of anyone feels interested. https://github.com/Techmo2/GM-Watchdog EDIT: Added a link to the binary on the GitHub readme because if you're like me, you're probably too lazy to compile it. If scrolling more than a few inches isn't your thing either, i'll add a link here. Edited July 1, 2018 by Techmo 7 Quote Link to comment Share on other sites More sharing options...
Pyrrhic Posted July 1, 2018 Share Posted July 1, 2018 Don't kick the dog 1 Quote Link to comment Share on other sites More sharing options...
Techmo Posted July 1, 2018 Author Share Posted July 1, 2018 Turns out the watchdog module was completely fine, the server just ignores the "Tick" hook if no players are online, and the timer never resets. The issue was fixed by setting sv_hibernate_think to 1. Quote Link to comment Share on other sites More sharing options...
Wolf Posted July 1, 2018 Share Posted July 1, 2018 This is good Quote Link to comment Share on other sites More sharing options...
Techmo Posted July 1, 2018 Author Share Posted July 1, 2018 Fixed the issue with hooks not working without players. The module enables hooks during hibernation when it starts up. Quote Link to comment Share on other sites More sharing options...
Techmo Posted July 9, 2018 Author Share Posted July 9, 2018 (edited) Finally decided to take the time to add scripting. When the timer is started, it reads a path from 'watchdog.cfg' located in the 'garrysmod' folder. It then starts the file defined (usually a batch file) when a crash is detected. The cfg file will be created when the server starts for the first time, but the path of the file to be executed needs to be placed inside. This path should be fully qualified, as it is not referenced from the directory of the cfg file itself. If you aren't in the compiling mood, I have the binary here. Edited July 9, 2018 by Techmo Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.