![ServerSync](https://media.forgecdn.net/avatars/thumbnails/254/696/256/256/637199290945083080.png)
Issues setting up
techtonictech opened this issue ยท 6 comments
so lets just leave it as im not terribly smart here and im not quite understanding how to set things up and the batch file is confusing me a fair bit.
so im wondering if you could update the instructions with like the lazy script
@echo off
SETLOCAL
for %%f in (forge*.jar) do (SET forge=%%~nxf)
for %%f in (serversync*.jar) do (SET serversync=%%~nxf)
start "Minecraft Server" java -Xms2g -Xmx2g -jar %forge% nogui
start "ServerSync Server" java -jar %serversync% server
ENDLOCAL
and then put another copy of the script representing things that might need modifying and such.
iv asked my programmer friends and there all clueless as to what this is what it does and what variables there are so im kinda at a lost.
thats what my current directory looks like and the server resides within server A
You can pretty safely ignore the batch script, it's just a no maintenance way to start the forge server & serversync at the same time (I'll explain it later on).
With your current setup all you need to do is put serversync in the folder 'server A' and add one extra line to your batch file.
start java -jar serversync<the version you are using>.jar server
java -Xmx... -jar forge... nogui
pause
Elipsis notation here indicating 'the rest of the arguments' (cause I'm a lazy bum ๐).
After you run serversync in server mode, note the server argument on the first line of the batch script, there will be a config file created in "server A\config\serversync*". (serversync-server.cfg)
This config file lets you add folders that you want to be synced to clients (starts with mods by default). You can also filter out files that you don't want to send to clients, such as the server only version of journeymap etc.
Whenever you start the forge server, serverysnc will also start. Clients (players) can then run serversync from their end and point it to your server address, this will serve the configured files to the client.
Note:
You can have serversync start automatically by putting it in the servers mods folder, however this will clutter your server console with logging & will needlessly tie serversync into the forge environment.
Explanation of the lazy start script.
@echo off
Turn off console output of the commands, this stops the console from splatting things like: 'for %%f in (forge*.jar) do (SET forge=%%~nxf) in your console and will only output explicitly logged entries.
SETLOCAL
Restrict the scope of the script to this batch only, stops variables from polluting the global space, they will not be available outside this script.
for %%f in (forge*.jar) do (SET forge=%%~nxf)
Loop over the files in this directory that match the pattern forge<anything>.jar, SET (create a variable) with the name 'forge' and store the matched file name in it. This will get us whatever version of the forge server is currently in the folder, if you decide later to update the version of forge the server is running you do not need to update the server start script as well ๐.
for %%f in (serversync*.jar) do (SET serversync=%%~nxf)
Same as forge above but gets you serversync regardless of version, this lets you drag & drop update serversync without any script maintenance headache.
start "Minecraft Server" java -Xms2g -Xmx2g -jar %forge% nogui
START - Start a new non blocking process
"Minecraft Server" - The name of the window for said process (you can call this whatever you like)
java -Xms2g -Xmx2g -jar - Java environment setup (starting memory allocation | max memory allocation | what you are doing, in this case running a jar file)
%forge% - put the contents of the forge variable that we created earlier here, this will contain the file name of the forge server
nogui - run in headless mode, without all the fancy graphs & stats
start "ServerSync Server" java -jar %serversync% server
Same as above but starting serversync in server mode, note that starting serversync without the server argument will start it in client mode.
ENDLOCAL
Turn off the local scope for variables etc.
I am using start specifically in this script as I don't want forge or serverysnc to block execution until their process finishes, thereby letting you run serversync and forge at the same time.
To adapt your current java environment setup to the lazy script just replace the forge server starting line with the one from your current batch file.
Put start before java.
Then replace the part: forge-1.12.2-14....jar with %forge%.
or, copy paste your java memory management setup from the current script and paste it in between the lazy scripts java and -jar parts, replacing the memory setup that is already there.
I'll modify the lazy script to have header variables to expose what can be configured.
Update the script on the wiki to:
@echo off
SETLOCAL
SET server_name=My Fancy Server
SET forge_java_arguments=-Xms2g -Xmx2g
SET serversync_java_arguments=
for %%f in (forge*.jar) do (SET forge=%%~nxf)
for %%f in (serversync*.jar) do (SET serversync=%%~nxf)
start "Forge - %server_name%" java %forge_java_arguments% -jar %forge% nogui
start "ServerSync - %server_name%" java %serversync_java_arguments% -jar %serversync% server
ENDLOCAL
Not sure if that's a whole lot easier, but it does mean you can basically ignore the bottom half of the script.