Dedicated Server Script - ED Forums
 


Notices

Reply
 
Thread Tools Display Modes
Old 02-16-2016, 09:53 PM   #1
Ciribob
ED Testers Team
 
Join Date: Mar 2015
Location: Brighton, UK
Posts: 1,706
Lightbulb Dedicated Server Script

With a few modifications to some internal DCS LUA files, you can make DCS load a Multiplayer server mission on launch....

The method WILL break when DCS updates and have to be redone, and is not for the faint hearted.

Firstly, make sure you server is set to auto login on start or you can't use this method.

Step one: use Notepad++ or another good editor to edit C:\Eagle Dynamics\DCS World\MissionEditor\MissionEditor.lua

Find the function onShowMainInterface and put in the code snippet between "DEDICATED CODE" below:

Code:
-- used in  __EMBEDDED__
function onShowMainInterface()
--print("--onShowMainInterface()---")
    if tooltipSkin_ == nil then
        tooltipSkin_ = Gui.GetTooltipSkin()
    else
        Gui.SetTooltipSkin(tooltipSkin_)
    end
    prepareMissionPath()
    mmw.setLastWallpaper()
    openReturnScreen()
	
	    -- START DEDICATED CODE -  ADD FROM THIS LINE    
        --
        if grgFirstRun == nil then
            grgFirstRun = true

            local net = require('net')
            local lfs = require('lfs')
            local Tools = require('tools')
            local mpConfig = Tools.safeDoFile(lfs.writedir() .. 'Config/serverSettings.lua', false)
            local dediConfig = Tools.safeDoFile(lfs.writedir() .. 'Config/dedicated.lua', false)
            
             if dediConfig and dediConfig.dedicated ~= nil and dediConfig.dedicated["enabled"] == true then
               net.set_name(dediConfig.dedicated["name"])
               net.start_server(mpConfig.cfg)
               net.log("Starting Dedicated Server...")
            end
        end
        --
        -- END DEDICATED CODE - ADD UP TO THIS LINE 
end
Step two: Create a file called dedicated.lua in C:\Users\<USER NAME>\Saved Games\DCS\Config and add:

Code:
dedicated = 
{

	["enabled"] = false,
	["name"] = "Server Player Name",

}
Step 3: Configure your server as normal using the normal server launcher and launch it once. This ensures the settings are saved to the normal config file.

Step 4: Quit DCS, edit the dedicated.lua in C:\Users\<USER NAME>\Saved Games\DCS\Config and set enabled to true like so:

Code:
dedicated = 
{

	["enabled"] = true,
	["name"] = "Server Player Name",

}
Step 5: Load DCS and marvel as after login it loads your multiplayer server!

If you ever want DCS to startup as normal so you can make modifications, edit the dedicated.lua and set enabled to false.

I highly recommend you do the registry tweak listed here so DCS doesnt show an error window and is easy to restart. http://forums.eagle.ru/showpost.php?...03&postcount=7

Note: If you press fly, you'll only be able to see the DCS home screen (dont worry the server is running!) and if you hit f10 you can see the map. Dont press buttons on the DCS home screen!

Next Steps: Use a program to automate the DCS Server launch and restart when crashed.

After a quick google I've found this and I'm going to try a few once I have some time: https://www.raymond.cc/blog/keep-app...n-when-closed/

Please don't hold me responsible if you wreck your DCS....

Thanks to Xcom, Greg and Crash for help and testing!

EDIT: Disable the windows error message so you can restart it easily - https://www.raymond.cc/blog/disable-...s-server-2008/
__________________
Scripts: Complete Transport And Logistics Deployment - CTLD / CTLD Examples - Lots of example of how to use CTLD
CSAR Script - Downed Pilot Rescue / Dedicated Server Script - Automatically launch DCS Multiplayer server at startup
Range Scoring Script - Get scores and counts hits on targets for gunnery or bombs / SimpleSlotBlock - Multiplayer dynamic Slot Blocking Script

Projects: DCS-SimpleRadio Standalone - DCS Radio Integration for All Aircraft - NO TeamSpeak Required!
DCS-SimpleRadio Troubleshooting Post / DCS-SimpleRadio Free Support Channel on Discord

Last edited by Ciribob; 04-25-2018 at 05:41 PM. Reason: Fixed spelling mistake
Ciribob is offline   Reply With Quote
Old 02-17-2016, 08:51 AM   #2
Pikey
Veteran
 
Pikey's Avatar
 
Join Date: Sep 2009
Location: Reading, UK (GMT)
Posts: 3,005
Default

I suspected you'd take an interest in this! Well if there wasn't a better example of using technology to automate a human action, this was it. I don't know what to say, but thank you seems to be an obvious start!

Does it detect when DCS is that state where its crashed but the process is still running? Any other states it can't cope with like Lua crashes? Should we supress Lua errors (ive found that leads it to crash instead)

Is there any additional testing you think is worth while?

Mike
__________________
“Six better fuses and we would have lost.”
Pikey is offline   Reply With Quote
Old 02-17-2016, 08:59 AM   #3
Ciribob
ED Testers Team
 
Join Date: Mar 2015
Location: Brighton, UK
Posts: 1,706
Default

Quote:
Originally Posted by Pikey View Post
I suspected you'd take an interest in this! Well if there wasn't a better example of using technology to automate a human action, this was it. I don't know what to say, but thank you seems to be an obvious start!

Does it detect when DCS is that state where its crashed but the process is still running? Any other states it can't cope with like Lua crashes? Should we supress Lua errors (ive found that leads it to crash instead)

Is there any additional testing you think is worth while?

Mike
So currently the script just loads and starts multiplayer when DCS Launches, it wont automatically restart it.

From that link in the original post, I need to try a few of the programs listed to try automatically restarting DCS when it crashes or if its memory usage becomes too high. It would be great if you could try some as well on your dedicated server and let me know which work well!

In theory with this script, and one of those programs, down time of a server should be minutes at most and restarts automated
__________________
Scripts: Complete Transport And Logistics Deployment - CTLD / CTLD Examples - Lots of example of how to use CTLD
CSAR Script - Downed Pilot Rescue / Dedicated Server Script - Automatically launch DCS Multiplayer server at startup
Range Scoring Script - Get scores and counts hits on targets for gunnery or bombs / SimpleSlotBlock - Multiplayer dynamic Slot Blocking Script

Projects: DCS-SimpleRadio Standalone - DCS Radio Integration for All Aircraft - NO TeamSpeak Required!
DCS-SimpleRadio Troubleshooting Post / DCS-SimpleRadio Free Support Channel on Discord
Ciribob is offline   Reply With Quote
Old 02-17-2016, 09:03 AM   #4
Ashilta
Member
 
Join Date: Mar 2011
Posts: 148
Default

Quote:
Originally Posted by Ciribob View Post
So currently the script just loads and starts multiplayer when DCS Launches, it wont automatically restart it.

From that link in the original post, I need to try a few of the programs listed to try automatically restarting DCS when it crashes or if its memory usage becomes too high. It would be great if you could try some as well on your dedicated server and let me know which work well!

In theory with this script, and one of those programs, down time of a server should be minutes at most and restarts automated
I'm quite sure it's possible to write a quick app that does it; it would simply monitor the list of running processes every X seconds, and if there's no process listed called DCSWorld.exe, re-start it!
Ashilta is offline   Reply With Quote
Old 02-17-2016, 09:04 AM   #5
Ciribob
ED Testers Team
 
Join Date: Mar 2015
Location: Brighton, UK
Posts: 1,706
Default

Yeah i was thinking, if you make DCS a service, windows should do it for you?
__________________
Scripts: Complete Transport And Logistics Deployment - CTLD / CTLD Examples - Lots of example of how to use CTLD
CSAR Script - Downed Pilot Rescue / Dedicated Server Script - Automatically launch DCS Multiplayer server at startup
Range Scoring Script - Get scores and counts hits on targets for gunnery or bombs / SimpleSlotBlock - Multiplayer dynamic Slot Blocking Script

Projects: DCS-SimpleRadio Standalone - DCS Radio Integration for All Aircraft - NO TeamSpeak Required!
DCS-SimpleRadio Troubleshooting Post / DCS-SimpleRadio Free Support Channel on Discord
Ciribob is offline   Reply With Quote
Old 02-17-2016, 09:26 AM   #6
Pikey
Veteran
 
Pikey's Avatar
 
Join Date: Sep 2009
Location: Reading, UK (GMT)
Posts: 3,005
Default

Quote:
Originally Posted by Ciribob View Post
Yeah i was thinking, if you make DCS a service, windows should do it for you?
Yeah, this manages restarting, what we need is a method to recognise a hung game.

Might I suggest a method? The game will need to create a heartbeat signal. In blue flag it would be your DynAB.lua, for others some other lua funciton that the external OS can recognise. If the files 'modified date' is not within parameters you know the game is no longer functioning and you can kill the process. It's a five line script in autoit, unfortuantely im not a developer and we should keep the languages consistent for support.

Autoit can use WMI calls for mem checks (im sure simple VBS can too), thats one thing it can do. I can't think of any symptoms other than that or 0% CPU. Its a shame I don't know how to interface things like the LUA process to commit a save or run an in game process before it does it as it might be more graceful and may catch things in time like a "save game state"

Any other snags?
__________________
“Six better fuses and we would have lost.”

Last edited by Pikey; 02-17-2016 at 09:30 AM. Reason: added wmi suggesiton
Pikey is offline   Reply With Quote
Old 02-17-2016, 09:35 AM   #7
gregzagk
3rd Party Campaign Creator
 
gregzagk's Avatar
 
Join Date: Aug 2011
Location: Germany
Posts: 1,229
Default

Quote:
Originally Posted by Pikey View Post
Yeah, this manages restarting, what we need is a method to recognise a hung game.

Might I suggest a method? The game will need to create a heartbeat signal. In blue flag it would be your DynAB.lua, for others some other lua funciton that the external OS can recognise. If the files 'modified date' is not within parameters you know the game is no longer functioning and you can kill the process. It's a five line script in autoit, unfortuantely im not a developer and we should keep the languages consistent for support.

Autoit can use WMI calls for mem checks (im sure simple VBS can too), thats one thing it can do. I can't think of any symptoms other than that or 0% CPU. Its a shame I don't know how to interface things like the LUA process to commit a save or run an in game process before it does it as it might be more graceful and may catch things in time like a "save game state"

Any other snags?
Right now when a "DCS stopped running" occurs in our server it closes completely so that we can see it off in the map. So it doen't stay hanged.

Crash did it through the Windows somehow. I will tell him to post how.

Greg
gregzagk is offline   Reply With Quote
Old 02-17-2016, 09:40 AM   #8
Ashilta
Member
 
Join Date: Mar 2011
Posts: 148
Default

Quote:
Originally Posted by Pikey View Post
Might I suggest a method? The game will need to create a heartbeat signal.
Is it possible from a mission dev point of view to just update a file every five minutes that can be monitored? Doesn't have to contain anything and so memory usage and disk IO would be minimal. I don't know LUA, but I can certainly knock up a windows app or service that monitors change in that file and takes the appropriate action.
Ashilta is offline   Reply With Quote
Old 02-17-2016, 09:57 AM   #9
gregzagk
3rd Party Campaign Creator
 
gregzagk's Avatar
 
Join Date: Aug 2011
Location: Germany
Posts: 1,229
Default

Quote:
Originally Posted by Ashilta View Post
Is it possible from a mission dev point of view to just update a file every five minutes that can be monitored? Doesn't have to contain anything and so memory usage and disk IO would be minimal. I don't know LUA, but I can certainly knock up a windows app or service that monitors change in that file and takes the appropriate action.
Crash is your man for this
He should be on tonight as nobody really knows what he has in the server... It's a mystery

Example
Quote:
2016-02-16 21:40,1,0,DCS.exe: running / ram: 2283.0 / swap: 2903.8
2016-02-16 21:45,-1,-1,DCS.exe: running / ram: 2348.9 / swap: 2967.2
2016-02-16 21:50,0,0,DCS.exe: running / ram: 2308.2 / swap: 2917.9
2016-02-16 21:55,3,15,DCS.exe: running / ram: 2617.7 / swap: 3263.3
2016-02-16 22:00,7,20,DCS.exe: running / ram: 2879.8 / swap: 3523.3
2016-02-16 22:05,14,30,DCS.exe: running / ram: 2938.0 / swap: 3590.8
2016-02-16 22:10,14,32,DCS.exe: running / ram: 2960.2 / swap: 3595.2
2016-02-16 22:15,17,35,DCS.exe: running / ram: 2991.8 / swap: 3618.6
2016-02-16 22:20,17,35,DCS.exe: running / ram: 3035.3 / swap: 3662.0
2016-02-16 22:25,20,37,DCS.exe: running / ram: 3053.8 / swap: 3677.2
2016-02-16 22:30,20,37,DCS.exe: running / ram: 3108.2 / swap: 3734.9
2016-02-16 22:35,21,35,DCS.exe: running / ram: 3164.3 / swap: 3789.0

Last edited by gregzagk; 02-17-2016 at 10:00 AM.
gregzagk is offline   Reply With Quote
Old 02-17-2016, 10:04 AM   #10
HiJack
Veteran
 
HiJack's Avatar
 
Join Date: Jul 2009
Location: Norway
Posts: 6,669
Default

Panzertard made a resart script once, check the forum for it. Sorry Im not able my self.
__________________
Windows 7 64 bit FTW!
My DCS Tools:
Quick Airfield information , Better trim with the X52 Pro , Tacview Glideslopes

Spoiler:

ASUS Z97-PRO, Socket-1150
Intel® Core i7-4770K Processor overclocked to @ 4.20 GHz
32GB Corsair Dominator Platinum DDR3 2133MHz CL9 4x8GB
Sapphire Radeon TRI-X R9 390X 8GB "OC"
Samsung SSD 850PRO 1TB SSD
WD 2TB Black 3,5", SATA64MB Cache, Dual Processor, 7200RPM
Windows 7 64-bit
Philips 40" 4K LED BDM4065UC, ASUS 27” and Dell 24” screens
HiJack is offline   Reply With Quote
Reply

Tags
dcs, dedicated, multiplayer

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. The time now is 03:36 PM. vBulletin Skin by ForumMonkeys. Powered by vBulletin®.
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.