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

[DEV] Autoreload plugins


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Plugin ID:
6978
Plugin Version:
1.15
Plugin Category:
General Purpose
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
    30 
    Plugin Description:
    Autoreloads plugins whose file timestamp has changed, for developers
    Old 03-13-2020 , 12:46   [DEV] Autoreload plugins
    Reply With Quote #1

    Description:
    By default, SourceMod reloads plugin on map change only (in case its file modification time is changed).
    This plugin does the same every 2 seconds (adjustable).
    *New features:
    - Notify in chat about reloading, loading, unloading.
    - Show plugin load status in chat
    - Can load newly added plugins (you must set it in ConVars!!!)
    - Can reload plugin even if the previous time it is failed
    - Can reload translation files cache (when some plugin is changed)
    - Scan in subfolders (recursively)
    - Ensure plugin is really loaded in case it was fault due to attempt to reload it in middle-time of file uploading
    - ConVars allowing to select delay (shorter, to track changes faster - for dev., or vice versa, longer delay to decrease CPU load - for production server)
    - Ability to show part of error log in chat when plugin failed to load
    - More optimized.
    Commands:
    PHP Code:
    // Forcibly check plugin files for newly updated and reload if any
    sm_pluginsreload 
    Settings (ConVars):
    Located at: cfg/sourcemod/sm_autoreload.cfg
    PHP Code:
    // Enable this plugin? (1 - Yes, 0 - No)
    sm_autoreload_enable "1"

    // * Delay between updates (in sec.). Set 0 to disable timer at all.
    sm_autoreload_delay "2.0"

    // ** Do we need to check for new plugin files appearing? (1 - Yes, 0 - No).
    sm_autoreload_track_new "0"

    // Where to show info about the reloaded plugin? (0 - Nowhere, 1 - Server, 2 - Chat, 4 - Console. Sum them to combine several options)
    sm_autoreload_show_info "3"

    // How many lines of error log to display when the plugin is failed to load? (0 - to disable)
    sm_autoreload_error_lines "4"

    // Display chat message to admins only defined by these admin flags (leave empty - to display for all users)
    sm_autoreload_msg_flag "" 
    *Notice 1: I would suggest setting like 5.0 - 10.0 sec. delay for production server where you don't need so quick plugin check.
    **Notice 2: track new files cause more disk operations since the entire folder has re-read each time. Leave disabled to improve performance.
    Forwards:
    Spoiler


    Using:
    Place smx in "plugins" folder.
    Credits:
    - Timiditas - author of idea and original plugin
    - SilverShot - testing, give me some ideas and forcing me find solutions ^^
    - Marttt - reload translation cache suggestion
    Full changelog:


    // TODO:
    - Integrity check.
    - Adding dynamically loaded/unloaded plugins to tracking list. Also, need help in issue #1482.


    Donate
    Donates are very appreciated and welcomed for further inspiration, make me happy, and make next updates came out more often:
    - Patreon (Paypal)
    - BitCoin
    - Ю.Money
    Attached Files
    File Type: zip ReloadPlugins.zip (20.7 KB, 338 views)
    __________________
    Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
    [My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

    Last edited by Dragokas; 10-06-2022 at 12:40.
    Dragokas is offline
    lugui
    Senior Member
    Join Date: Feb 2016
    Location: GetClientAbsOrigin();
    Old 03-13-2020 , 20:46   Re: [DEV] Plugin reload
    Reply With Quote #2

    good, that will save me one or two seconds on each reaload when I testing my plugins... I gess it will add up to a few minutes =P
    __________________
    Add me for commissions!
    Steam: [U:1:88621772]
    Discord: lugui#0889
    My Plugins

    Last edited by lugui; 03-13-2020 at 20:46.
    lugui is offline
    Silvers
    SourceMod Plugin Approver
    Join Date: Aug 2010
    Location: SpaceX
    Old 03-14-2020 , 01:41   Re: [DEV] Plugin reload
    Reply With Quote #3

    At last can add new plugins without having to refresh the plugins list (albeit I use sm_refresh but still typing in console when Im not in-game using the keybind I set).

    Thanks!
    __________________
    Silvers is offline
    Alienmario
    Senior Member
    Join Date: Aug 2013
    Old 03-16-2020 , 11:27   Re: [DEV] Plugin reload
    Reply With Quote #4

    Thanks!
    Alienmario is online now
    Dragokas
    Veteran Member
    Join Date: Nov 2017
    Location: Ukraine on fire
    Old 03-16-2020 , 19:50   Re: [DEV] Plugin reload
    Reply With Quote #5

    Updated.

    Quote:
    1.6 (17-Mar-2020)
    - Code is simplified, changed timing logic.
    - Plugin load status is now always displayed (it's checked with 0.5 sec. delay after actual re-loading).
    - Status description is simplified.
    - Plugin change is now detected by file size as well.
    - "sm_autoreload_delay" ConVar safe minimum is defined as 1.0 sec.
    - Disabled load/reload selection logic based on plugin status, since FindPluginByFile returns 0 even if plugin is loaded but disabled. Now, reload + load is always executed together.
    - Added ability to display in chat part of error log when plugin is failed to load (you can disable or adjust number of lines in "sm_autoreload_error_lines" ConVar).
    - Added an option to display info in console only, see "sm_autoreload_show_info" description.

    1.5 (16-Mar-2020)
    - Better file uploading finish detection, so no more twice spam in error log (thanks to SilverShot).
    - Some message misprints corrected.
    __________________
    Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
    [My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
    Dragokas is offline
    Marttt
    Veteran Member
    Join Date: Jan 2019
    Location: Brazil
    Old 03-21-2020 , 13:39   Re: [DEV] Plugin reload
    Reply With Quote #6

    I don't know if it will be a good addition, but I'm used to run the "sm_reload_translations" together with the "sm plugins refresh", to reload the translations file (because some times I have to update both .smx and .phrases file),

    So maybe you can include that in the plugin and make a cvar (maybe not necessary) allowing it to reload the translations file (at the end) if some plugin is updated.

    IMO is just a suggestion to improve it.

    Thanks for you effort. Nice plugin as always.
    __________________

    Last edited by Marttt; 04-06-2022 at 09:58.
    Marttt is online now
    Dragokas
    Veteran Member
    Join Date: Nov 2017
    Location: Ukraine on fire
    Old 03-22-2020 , 06:42   Re: [DEV] Plugin reload
    Reply With Quote #7

    Thanks for suggestion, Marttt! Very useful.

    Updated.

    Quote:
    1.8 (22-Mar-2020)
    - Attempt to indirectly recognize <Disabled> plugins to prevent both load / reload commands executing for each modified plugin (affected rcon double-msg only).
    - Added reloading of translation files cache; can be triggered by any of plugins reload (Marttt suggestion).
    - Added ability to display reload message to admins only: new ConVar "sm_autoreload_msg_flag" (e.g., useful to not distract the players).
    - Added ability to disable reloader: new ConVar "sm_autoreload_enable" (e.g. useful when some plugin can surely crash the server due to "hot" reload).

    1.7 (18-Mar-2020)
    - Some non-essential message cleaning
    __________________
    Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
    [My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
    Dragokas is offline
    CrazyGhostRider
    Member
    Join Date: Apr 2014
    Location: Russia
    Old 03-31-2020 , 16:21   Re: [DEV] Plugin reload
    Reply With Quote #8

    You have a mistake. Instead of reloading the updated plugin, the "Loading" of the plugin occurs.
    CrazyGhostRider is offline
    Dragokas
    Veteran Member
    Join Date: Nov 2017
    Location: Ukraine on fire
    Old 03-31-2020 , 17:26   Re: [DEV] Plugin reload
    Reply With Quote #9

    Can you show server logs?
    __________________
    Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
    [My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
    Dragokas is offline
    CrazyGhostRider
    Member
    Join Date: Apr 2014
    Location: Russia
    Old 04-01-2020 , 05:41   Re: [DEV] Plugin reload
    Reply With Quote #10

    I replace the file speclist.smx

    [AutoReload] test/speclist.smx has changed timestamp. Reloading...
    [SM] Plugin test\speclist.smx is already loaded.
    sm plugins reload test/speclist
    [SM] Plugin Spectator List reloaded successfully.


    sm_autoreload_delay = 2.0
    sm_autoreload_track_new = 1
    sm_autoreload_error_lines = 4



    P.S. Another error with chat messages if you delete a file. And then add the file again
    test/speclist2.smx plugin is deleted. Unloading...
    test/speclist2.smx plugin reloaded. Status: NOT Loaded

    But in the server console it writes like this:
    [AutoReload] test/speclist2.smx plugin is deleted. Unloading...
    [SM] Plugin Spectator List unloaded successfully.
    [AutoReload] test/speclist2.smx has changed timestamp. Reloading...
    [SM] Loaded plugin test\speclist2.smx successfully.

    Last edited by CrazyGhostRider; 04-01-2020 at 11:30.
    CrazyGhostRider 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 19:50.


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