#Server restart batch

1 messages ยท Page 1 of 1 (latest)

daring ingot
#
:loop
tasklist /fi "ImageName eq CoreKeeperServer.exe" /fo csv 2>NUL | find /I "CoreKeeperServer.exe">NUL
if "%ERRORLEVEL%" NEQ "0" start powershell -executionpolicy unrestricted -File Launch.ps1 %*
timeout 10
goto loop``` as Launch.bat
#
# Feel free to change these (see README), but keep in mind that changes to this file might be overwritten on update
$Date = Get-Date -format "yyyyMMdd"
$DateStr = './logs/CoreKeeperServerLog-{0:yyyyMMdd}.txt' -f $Date
$CoreKeeperArguments = @("-batchmode", "-hardmode", "-logfile", $DateStr) + $args
$script:ckpid = $null

function Quit-CoreKeeperServer {
    if ($script:ckpid -ne $null) {
        taskkill /pid $ckpid.Id
        Wait-Process -InputObject $ckpid
        Write-Host "Stopped CoreKeeperServer.exe"
    }
}

try {
    if (Test-Path -Path "GameID.txt") {
        Remove-Item -Path "GameID.txt"
    }

    $script:ckpid = Start-Process -PassThru -FilePath %0\..\CoreKeeperServer.exe -ArgumentList $CoreKeeperArguments
    Write-Host "Started CoreKeeperServer.exe"

    # Wait for GameID
    while (!(Test-Path -Path "GameID.txt")) {
        Start-Sleep -Milliseconds 100
    }
    
    Get-Process | Where-Object { $_.MainWindowTitle -like 'CoreKeeperPowershell' } | Stop-Process
    $host.UI.RawUI.WindowTitle = "CoreKeeperPowershell"
    
    Write-Host -NoNewline "Game ID: "
    Get-Content "GameID.txt"
    Write-Host "Press q to quit, DON'T close the window or the server process will just keep running"
       While ($KeyInfo.VirtualKeyCode -eq $Null -or $KeyInfo.VirtualKeyCode -ne 81) {
        $KeyInfo = $Host.UI.RawUI.ReadKey("NoEcho, IncludeKeyDown")
    }
}
finally {
    Quit-CoreKeeperServer
    pause
}
``` as Launch.ps1
loud arch
#

Nice. I'll have to take a closer look in an IDE (can optionally go with triple backtick PowerShell to syntax highlight)

daring ingot
#

good call

loud arch
#

IDK if batch has one? eh it's short though

daring ingot
#

ye idk

#

all it does is look at process list and if server isn't running closes the PS window and starts server

#

Which is why I gave PS window a special name ๐Ÿ™‚

loud arch
#

Ah gotcha

#

Thar she be

while (!(Test-Path -Path "GameID.txt")) {
        Start-Sleep -Milliseconds 100
    }```
daring ingot
#

actually the kill old PS is in the Launch.PS1 lol

#

err ps1

loud arch
#

So much fun lol

#

I cringe that bat uses goto, but hey it does the trick

#

Using it is fine, but having goto at all I mean lol

daring ingot
#

IDK it's been a long time since I did anything batch related

#

is there an alternative now?

loud arch
#

No clue, bat makes me sad panda

#

I learned a ton since I last did that Astroneer thing, but I'd totes use jobs now

daring ingot
#

I don't imagine so, seeing as PowerShell is a thing

loud arch
#

Execution is the nasty bit with PS1, so bat still has uses

daring ingot
#

I also have no real experience with PS1

#

Changed it to add date to the log file so at the very least it won't overwrite from day to day

#

And store in the logs folder since it's already there

#

Maybe some day Iโ€™ll add proper backing up but not rn

#

@turbid turtle hereโ€™s the stuff if you want it

turbid turtle
#

Noice! You wanna share it on that Reddit thread? And on the wiki?

I asked you guys cos I have no experience here and I'm not exactly firing on all cylinders today... ๐Ÿ˜ฎโ€๐Ÿ’จ

daring ingot
#

Ahh I might post on Reddit but im also not signed in on my pc lol. Dont have a wiki account so I would have to make one

turbid turtle
#

Well, you or @loud arch , whatever. ๐Ÿ˜‰ I think one can edit anonymously...?

daring ingot
#

lol I logged in to reddit and it says I'm not logged in so I can't comment, but then when I click log in it says I'm logged in and reloads the page. Nice

#

reddit dying rn

#

@misty plover I assume you're the person who posted on reddit since it links to the same YouTube channel as your profile here.

misty plover
#

โค๏ธ

#

Thank you mate!

daring ingot
#

Also there's a chance updates to the dedicated server will overwrite Launch.ps1 so you could rename it and have batch file launch whatever the new one is called.

misty plover
#

Yup, I guess will see tomorrow.

turbid turtle
#

Wiki is sad.... And lonely... ๐Ÿ˜ข

daring ingot
#

I was hoping @loud arch would do the setup server bit cuz Iโ€™m too lazy to write it all lmao

#

Been busy and off the pc a lot

turbid turtle
#

I mean, there's existing guide instruction to copy. I mostly would like (1 of) you guys to confirm them and add any details or contingencies that have been overlooked. Maybe draw straws....? ๐Ÿฅบ

daring ingot
#

idgi codeblocks are weird on this site lol

#

Guess I'll just chuck the files in there

#

or not

#

This has only happened once in my life

#

Honestly

turbid turtle
#

Wikizet is @simple root's domain. The server uses Wikimedia with some customised templates.

daring ingot
#

codeblocks is four spaces on both sides

#

lmfao

#

and it doesn't work with multiline stuff

#

All done and submitting it I guess

#

@loud arch you don't mind if I put your Discord username at the bottom with mine since you made the main instructions I used for installation, or would you prefer I not?

turbid turtle
daring ingot
#

yea you need to start each line with four spaces

#

which is annoying

#

I just dunno if I should include Xechs discord cuz I can imagine it might lead to a lot of rando messages

#

I don't mind mine in case the restart script gets broken

turbid turtle
daring ingot
#

Might think about making one on Docker images but IDK anything about those so

loud arch
#

Sure thing!

daring ingot
#

I wish the steam:// link worked

#

I like how it decided โ€œPaste into browser barโ€ is the most significant thing to quote for the embed

turbid turtle
daring ingot
#

Never change, Discord. Never change.

#

Man. more writing? Lmao

turbid turtle
#

Which is probably advisable: "This guide explains how to ... "

daring ingot
#

I was never good at actually buckling down to write anything lol

daring ingot
#

I still wanna make the joke tho

turbid turtle
#

I mean, it kinda looks like you just did? And did it quite fast. Thanks. ๐Ÿ™‚

I might see if I can follow it, sometime, as a test.

daring ingot
#

Iโ€™m a programmer not an english major

daring ingot
turbid turtle
#

Why's the official instructions so much longer?: #โ”-faq-and-links message

Where yours are just:
Paste into browser address bar steam://install/1963720

daring ingot
#

That's a direct link that calls for Steam to install the dedicated server using URI (Uniform Resource Identifier). Kinda like how you can join Roblox games directly from the website instead of launching the Roblox program and joining that way.

#

Should I put both in there?

#

If you change install to uninstall you'll see how it works

#

((it'll still ask you to install or uninstall))

#

steam://uninstall/1963720

turbid turtle
#

Oh, you can literally paste it into any browser, not the steam client, huh.

I think there needs to be a "basic" instructions section. That explains about leaving the window open, what it looks like, etc. At the top. Preferably with a contextual screenshot (which I could add later, maybe).

daring ingot
#

I mean it literally says as much when you launch it

turbid turtle
#

Heh. It can be nice to know what to expect. And that was one part of it.

daring ingot
turbid turtle
#

Cool. Thanks.๐Ÿ‘ I'll take a proper look some time later. ๐Ÿ™‚

simple root
#

@daring ingot @turbid turtle multiline codes can be inserted with <pre></pre>

#

<code></code> is for inline code

daring ingot
#

I got it workin with just leading every line with 4 spaces but I'll remember for future ๐Ÿ˜›

simple root
#

The wiki is using mediawiki, so if you need syntax reference google mediawiki + keyword

daring ingot
#

sick thanks ๐Ÿ™‚

turbid turtle
#

I said "wikimedia" above, didn't I... ๐Ÿ˜…

daring ingot
#

Probably

#

I'm smooth brain a lot of the time