[Server] Reload JS File

Post your suggestions here
Post Reply
MxSimulatorMods
Crushed Dissenter
Posts: 62
Joined: Fri Aug 03, 2018 6:37 pm

[Server] Reload JS File

Post by MxSimulatorMods »

Hi JLV,

It will be great if we can reload js files on the server without restart it. With this feature, we have not to setup again all tracks on it after each little update on js.
Image
Wahlamt
Posts: 7934
Joined: Mon Sep 13, 2010 3:15 pm
Team: MLG Compton
Location: Sweden
Contact:

Re: [Server] Reload JS File

Post by Wahlamt »

How do you mean, like if you add a track?
MxSimulatorMods
Crushed Dissenter
Posts: 62
Joined: Fri Aug 03, 2018 6:37 pm

Re: [Server] Reload JS File

Post by MxSimulatorMods »

Yes, may be. Or just a command which reloads all js scripts like 'server, reloadjs'
Image
Wahlamt
Posts: 7934
Joined: Mon Sep 13, 2010 3:15 pm
Team: MLG Compton
Location: Sweden
Contact:

Re: [Server] Reload JS File

Post by Wahlamt »

You could double it. Like *inserting stuff in js file via GUI button click* also runs something like:

Code: Select all

x<XCMD PASSWORD>server,addtrack <time> <laps> <change interval> <trackinfo>
or
x<XCMD PASSWORD>server,removetrack <track number>
It perhaps isn't the full solution you want, but for specifically adding tracks, this could work.
jlv
Site Admin
Posts: 14931
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: [Server] Reload JS File

Post by jlv »

You could try 'eval(mxserver.file_to_string("myscript.js"))'. You'd have to make sure you reset any handlers you hooked at the start of your script to avoid turning the handler chain into a loop. I'd feel safer just restarting the server.

It'd also be possible to save your track list and reload it when the server starts.
Josh Vanderhoof
Sole Proprietor
jlv@mxsimulator.com
If you email, put "MX Simulator" in the subject to make sure it gets through my spam filter.
MxSimulatorMods
Crushed Dissenter
Posts: 62
Joined: Fri Aug 03, 2018 6:37 pm

Re: [Server] Reload JS File

Post by MxSimulatorMods »

It's not just for tracks. It's also to allow me to make a little update without have to ask at all players to come back after few minutes.
If I could restart js without restart server, it will be easier for me to fix issues very fast on MxsRank.
Image
jlv
Site Admin
Posts: 14931
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: [Server] Reload JS File

Post by jlv »

Probably best to just do the eval thing in that case and be careful with the hooks. The default handlers are all just empty functions so it's safe to not call them.
Josh Vanderhoof
Sole Proprietor
jlv@mxsimulator.com
If you email, put "MX Simulator" in the subject to make sure it gets through my spam filter.
Post Reply