Raised This Month: $32 Target: $400
 8% 

How to detect if server crashed?


Post New Thread Reply   
 
Thread Tools Display Modes
danonix
Senior Member
Join Date: Dec 2012
Old 02-10-2015 , 10:15   Re: How to detect if server crashed?
Reply With Quote #11

Quote:
Originally Posted by aron9forever View Post
as far as I know servers auto restart when debug=""
that stops working if the process is killed(which means something went horribly wrong)

to be somewhat helpful to the OP, you can not do this with amxx
even bugsy's idea won't work because it won't give you the exact time of the crash and hosting providers usually fail to restart the server if the process is kill, then you won't get the accurate timestamp

What you want is very possible and easy to accomplish with PHP and a cron job if you have some knowledge in that area
No, not really. Though that it is possible via amxx. Using plugin_end() is a good option, or server won't catch this event while crash?
danonix is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 02-10-2015 , 11:24   Re: How to detect if server crashed?
Reply With Quote #12

Quote:
Originally Posted by danonix View Post
No, not really. Though that it is possible via amxx. Using plugin_end() is a good option, or server won't catch this event while crash?
If the server crashes it crashes. It is immediately gone for good and there is nothing to catch and no events to process.


Galileo uses a neat trick to detect server restarts. It registers a special cvar, gal_server_starting, with a default value of 1 and executes a special function if that default value is detected. That function sets the cvar to 0 and then executes the server restart/crash logic. Provided nothing tinkers with that cvar and the plugin is loaded at all times the cvar will only ever be set to 1 on server start, when Galileo initially registers it. It also writes some extra information into a file so it knows what the last played map is.

If you really need a time for the crash you could combine this method with a function that writes the current time into a file once per minute, so when you detect a server restart with the cvar you can use that stored time to give an estimate for the crash time.
__________________
In Flames we trust!
Nextra is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-10-2015 , 23:08   Re: How to detect if server crashed?
Reply With Quote #13

Quote:
Originally Posted by aron9forever View Post
even bugsy's idea won't work because it won't give you the exact time of the crash and hosting providers usually fail to restart the server if the process is kill, then you won't get the accurate timestamp

What you want is very possible and easy to accomplish with PHP and a cron job if you have some knowledge in that area
I find it odd that GSP's would not re-start a crashed server. My method would work fine as long as the server gets restarted. If there is a restart service, you can detect a crash time within a few seconds of the crash.
__________________
Bugsy is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 08-16-2018 , 08:45   Re: How to detect if server crashed?
Reply With Quote #14

Sorry for reviving an old thread, but I think it's better to post here rather than opening a new topic. So my question is, what would be the best way to optimize a plug-in regarding saving to file vault? I'm developing a credits system that will give credits to players on every kill. Data is stored in a trie as cell by steamid. All works fine. My question here is about fvault. I know that a good idea would be to save everything before map changes, on plugin_end, but what if the server crashes? EntMod can crash servers and there is no possible way to fix that. It doesn't happen all the time and should not happen on maps designed for entmoving. So in my case, when do you think that it'll be best to save the credits to the file? Everytime credits are updated? I don't want people to come on the server after it crashed and realise that their credits are lower just because they couldn't be saved to the vault. The credits plug-in is not done, I just started working on it today. Thanks !

Last edited by DarthMan; 08-16-2018 at 08:46.
DarthMan is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-16-2018 , 09:04   Re: How to detect if server crashed?
Reply With Quote #15

Quote:
Originally Posted by DarthMan View Post
Sorry for reviving an old thread, but I think it's better to post here rather than opening a new topic. So my question is, what would be the best way to optimize a plug-in regarding saving to file vault? I'm developing a credits system that will give credits to players on every kill. Data is stored in a trie as cell by steamid. All works fine. My question here is about fvault. I know that a good idea would be to save everything before map changes, on plugin_end, but what if the server crashes? EntMod can crash servers and there is no possible way to fix that. It doesn't happen all the time and should not happen on maps designed for entmoving. So in my case, when do you think that it'll be best to save the credits to the file? Everytime credits are updated? I don't want people to come on the server after it crashed and realise that their credits are lower just because they couldn't be saved to the vault. The credits plug-in is not done, I just started working on it today. Thanks !
Memory consuming method:
- Set a task and repeat 1.0 second, close and re-open vault, save data.

Less memory consuming method:
- Close and re-open vault on round start, save data.
__________________
edon1337 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 08-16-2018 , 09:11   Re: How to detect if server crashed?
Reply With Quote #16

Having a task has nothing to do with consuming memory.
__________________
klippy is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 08-16-2018 , 09:20   Re: How to detect if server crashed?
Reply With Quote #17

Quote:
Originally Posted by KliPPy View Post
Having a task has nothing to do with consuming memory.
That's true. I think I'll keep it the way it was, saving to the vault everytime the credits are updated.
DarthMan is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-16-2018 , 11:25   Re: How to detect if server crashed?
Reply With Quote #18

Quote:
Originally Posted by KliPPy View Post
Having a task has nothing to do with consuming memory.
Saving data every second for 32 players isn't memory consuming?
__________________

Last edited by edon1337; 08-16-2018 at 11:29.
edon1337 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 08-16-2018 , 11:49   Re: How to detect if server crashed?
Reply With Quote #19

Quote:
Originally Posted by edon1337 View Post
Saving data every second for 32 players isn't memory consuming?
You read the vault file and then write it - you are reusing memory, it's not consuming more. The frequency doesn't matter.
__________________

Last edited by klippy; 08-16-2018 at 11:50.
klippy is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 08-16-2018 , 11:52   Re: How to detect if server crashed?
Reply With Quote #20

I think he meant other thing.
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM
Ghosted is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:16.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode