CM2Walki / CSGO

Dockerfile for automated build of a CS:GO gameserver: https://hub.docker.com/r/cm2network/csgo/
https://CM2.Network
MIT License
249 stars 74 forks source link

Container fails to start #38

Closed Nuc1eoN closed 4 years ago

Nuc1eoN commented 4 years ago

When I am trying to run your container I am getting

bash: entry.sh: No such file or directory

And then the container exits.

The command I use:

podman run -d --net=host -v ~/podman.d/volumes/csgo/:/home/steam/csgo-dedicated/ --name=csgo-dedicated2 cm2network/csgo
Nuc1eoN commented 4 years ago

It was definitely an error on my side as -v /home/steam/csgo-dedicated/ resolved the issue.

I wonder, how would I bind /home/steam/csgo-dedicated/ to a specific directory on my file system though? With other images that I use, commands like -v ~/podman.d/volumes/csgo/:/home/steam/csgo-dedicated/ work fine to bind a guest directory to a host directory.

CM2Walki commented 4 years ago

This is a known issue, I'm currently propagating through my game server images. The entrypoint's entry.sh is in that volume, so if you do a bind mount, you also obscure the entry.sh inside the container. This is fixed by moving the entry.sh outside the steam app dir, see CM2Walki/TF2#6.

I'll do the change now and trigger a new build, this should fix the issue.

CM2Walki commented 4 years ago

Can you repull the image and try again?

Nuc1eoN commented 4 years ago

Thanks! It seems there are still some errors left

Connecting anonymously to Steam Public...Logged in OK
Waiting for user info...OK
ERROR! Failed to install app '740' (Disk write failure)
sed: can't read /home/steam/csgo-dedicated/csgo/cfg/server.cfg: No such file or directory
bash: /home/steam/csgo-dedicated/srcds_run: No such file or directory
CM2Walki commented 4 years ago

This seems to be an issue with your machine, are you sure you have enough disk space and that the volume is writeable?

EDIT: nvm, I'm experiencing a similar issue on my end, hang on.

Nuc1eoN commented 4 years ago

Hey so on my end, it only fails in podman rootless mode.

I managed to get it working by passing the --userns=keep-id parameter in rootless mode.

EDIT: I wonder why you've had a similar issue? Are you on rootless podman?

CM2Walki commented 4 years ago

Sorry for the delay @Nuc1eoN. Could you try to pull & relaunch the container? Everything should be working as intended now, thanks for helping me debug the issue.

Nuc1eoN commented 4 years ago

Hey @CM2Walki so for me the fix was (and still is) to add --userns=keep-id to my rootless container.

I am not sure what your issue was but maybe I would have faced it at a later stage.

Thanks for the help!

Nuc1eoN commented 4 years ago

Actually I need to re-open the issue. I now let the whole CSGO download finish and at the very end I am getting an error:

 Update state (0x61) downloading, progress: 99.50 (24667192413 / 24791608158)
 Update state (0x61) downloading, progress: 99.75 (24729197944 / 24791608158)
 Update state (0x61) downloading, progress: 99.98 (24787358363 / 24791608158)
Success! App '740' fully installed.
sed: can't read /home/steam/csgo-dedicated/csgo/cfg/server.cfg: No such file or directory
ERROR: Invalid game type 'csgo' sepecified.
Sat Aug 22 18:31:25 UTC 2020: Server Failed

Using the cm2network/csgo:sourcemod image.

Do you know what it could be?

xoryouyou commented 4 years ago
WARNING: setlocale('en_US.UTF-8') failed, using locale: 'C'. International characters may not work.
Redirecting stderr to '/home/steam/Steam/logs/stderr.txt'
[  0%] Checking for available updates...
[----] Verifying installation...
[  0%] Downloading update...
[  0%] Checking for available updates...
[----] Download complete.
[----] Extracting package...
[----] Extracting package...
[----] Extracting package...
[----] Extracting package...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Cleaning up...
[----] Update complete, launching Steamcmd...
WARNING: setlocale('en_US.UTF-8') failed, using locale: 'C'. International characters may not work.
Redirecting stderr to '/home/steam/Steam/logs/stderr.txt'
[  0%] Checking for available updates...
[----] Verifying installation...
Steam Console Client (c) Valve Corporation
-- type 'quit' to exit --
Loading Steam API...OK.

Connecting anonymously to Steam Public...Logged in OK
Waiting for user info...OK
Success! App '740' already up to date.
sed: can't read /home/steam/csgo-dedicated/csgo/cfg/server.cfg: No such file or directory
ERROR: Invalid game type 'csgo' sepecified.
Sat Aug 22 20:37:38 UTC 2020: Server Failed

Same here when trying to mount the csgo directory via a volume bind. -v $(pwd)/dedicated/:/home/steam/csgo-dedicated/

CM2Walki commented 4 years ago

Thanks guys. I had build caching enabled on docker hub, so the fix I did to the entry.sh didn't get built. The issue is resolved now, I tested it myself.

For anyone coming across this issue in relation to:

ERROR: Invalid game type 'csgo' sepecified.

This happens if you execute the srcds_run whilst being in a different directory. Just cd to it before you call it and you'll be fine.

Nuc1eoN commented 4 years ago

@CM2Walki hey bro thanks for the ongoing maintenance and support for your images!

The server starts fine! Although it seems there's still one error left for me:

sed: can't read /home/steam/csgo-dedicated/csgo/cfg/server.cfg: No such file or directory

I don't think that is expected, is it?

CM2Walki commented 4 years ago

I don't receive this error. Can you give me a bit more log context? Is the server.cfg missing on your end for whatever reason?

Nuc1eoN commented 4 years ago

Is the server.cfg missing on your end for whatever reason?

Correct, the server.cfg is missing in my setup out of some reason.

EDIT: some log context

 Update state (0x61) downloading, progress: 99.40 (24642117514 / 24791608158)
 Update state (0x61) downloading, progress: 99.62 (24697960993 / 24791608158)
 Update state (0x61) downloading, progress: 99.88 (24762002245 / 24791608158)
Success! App '740' fully installed.
sed: can't read /home/steam/csgo-dedicated/csgo/cfg/server.cfg: No such file or directory
Server will auto-restart if there is a crash.
Updating server using Steam.
----------------------------
/home/steam/csgo-dedicated/srcds_run: line 301: ./steam.sh: No such file or directory
----------------------------
Setting breakpad minidump AppID = 740
Using breakpad crash handler
Forcing breakpad minidump interfaces to load
Looking up breakpad interfaces from steamclient
Calling BreakpadMiniDumpSystemInit
[S_API] SteamAPI_Init(): SteamAPI_IsSteamRunning() did not locate a running instance of Steam.
[S_API] SteamAPI_Init(): Loaded '/home/steam/.steam/sdk32/steamclient.so' OK.
[S_API FAIL] SteamAPI_Init() failed; create pipe failed.LD_LIBRARY_PATH=/home/steam/csgo-dedicated/bin:/home/steam/csgo-dedicated:/home/steam/csgo-dedicated/bin:
#
#Console initialized.
#Using breakpad minidump system 740/13764.1176.DC
#Loading VPK file hashes for pure server operation.
CM2Walki commented 4 years ago

I think I know what the issue is, the initial config gets hidden by the bind mount. That might be a bit iffy to fix.

Nuc1eoN commented 4 years ago

@CM2Walki yeah I see... Upon further looking into the issue I've noticed that metamod/sourcemopd does not get installed either, when using the csgo:sourcemod variant. There is no addons folder under csgo/.

EDIT: Maybe it would be worth looking at https://github.com/kaimallea/csgo as it seems to explicitly support bind mounts (according to the readme) and also installing plugins.

CM2Walki commented 4 years ago

I found a solution myself. This will add the missing files if you use a bind mount, it just repeats the Dockerfile steps if the server.cfg is missing.

https://github.com/CM2Walki/CSGO/blob/73f84a0624560f68920fcf74672412de49e90fe6/etc/entry.sh#L9-L25

I'm currently testing the solution.

Nuc1eoN commented 4 years ago
    # Are we in a metamod container? 
    if [ ! -z "$METAMOD_VERSION" ]; then 
        LATESTMM=$(wget -qO- https://mms.alliedmods.net/mmsdrop/"${METAMOD_VERSION}"/mmsource-latest-linux) 
        wget -qO- https://mms.alliedmods.net/mmsdrop/"${METAMOD_VERSION}"/"${LATESTMM}" | tar xvzf - -C "${STEAMAPPDIR}/${STEAMAPP}"     
    fi 

Does it even makes sense to bake stuff like server.cfg/metamod/sourcemod into the image then? If I understand correctly this would download metamod/sourcemod no matter if it's in the file system or not.

Probably some kind of check could also be implemented as you did with server,cfg. But on the other side it could be done purely in the entry.sh without baking it into the image, too.

I'm no docker guru though. Just throwing out some stuff that came to my mind.

CM2Walki commented 4 years ago

It still makes sense if you don't use a bind mount. I have to admit though that this is not the best solution. I guess we could get rid of the Dockerfile bit and just save the space.

Nuc1eoN commented 4 years ago

It still makes sense if you don't use a bind mount.

It would simply move the server customization process from build to initialization time.

Do you think there would be any drawbacks?

CM2Walki commented 4 years ago

Change has been applied, everything should work as intended now. I also added a section in the README.md that explains how to host a server with a bind mount. The previous in Dockerfile volume approach is back as well.

Nuc1eoN commented 4 years ago

@CM2Walki Love the simplicity of the solution.. awesome!

Everything seems to work as expected now. Closing.