Skip to content

Crash Script

NeverwinterWightsNeverwinterWights Member Posts: 339
edited January 2022 in Builders - Scripting
I'm looking for a reliable, trusty server crash script. Not for anything malicious. Just need it to shut down a server for a restart, similar to what NWNX does. Been trying some things to no avail. Any ideas?
Post edited by NeverwinterWights on

Comments

  • ReachPWReachPW Member Posts: 27
    edited January 2022
    A crude way to do this is to use the built in database. Just make a single database with a value of SHUTDOWN and set it to 0 on startup. When you want to shut it down, just set it to 1.

    Then have a external script* look for this value, set it back to 0 and just send a kill command to the nwserver pid.

    * The built in database is sqlite, so can use any tool or library you want to read/write it (it's a very well supported database).

    Post edited by ReachPW on
  • NeverwinterWightsNeverwinterWights Member Posts: 339
    edited January 2022
    ReachPW wrote: »
    A crude way to do this is to use the built in database. Just make a single database with a value of SHUTDOWN and set it to 0 on startup. When you want to shut it down, just set it to 1.

    Then have a external script* look for this value, set it back to 0 and just send a kill command to the nwserver pid.

    * The built in database is sqlite, so can use any tool or library you want to read/write it (it's a very well supported database).

    Hmm. I will take that into consideration. I was hoping to do this specifically via in-game script. I'm pretty sure that is how NWNX does it. It causes an intentional crash at a specified time and then Watchdog sees the server went down and restarts it. If there is anyway to currently do this via in game scripting without using NWNX, that would be ideal for my needs. It seems that all the previous methods have been fixed. I haven't tried taking/destroying an item from an inventory item in an inventory item yet. Was hoping there might be something more simple and less convoluted.

    I am currently using Game Server Manager which acts similarly to Watchdog and works great. It does have options to restart the server but only once per day at a specified time or at intervals of however many hours. But if you use the intervals it will be every so many hours from when you started the server which could be weird random times (ie, the server will reset every 12 hours at 1:43). And this is my current issue. In game I now have sql functions to get real time so I have already figured out the server restart warning messages and can restart it at real times at any time of choosing. I'm just missing the way to "crash" it or shut it down.
  • ReachPWReachPW Member Posts: 27
    edited January 2022
    If you want to do a "soft restart" you can do it like this
    StartNewModule("my_module_name");
    

    That'll reload module without restarting server. But for a hard restart you need NWNX or external command. You just need something to trigger a `kill` command in linux or `taskkill` in windows with the server pid or image name.




Sign In or Register to comment.