-1

I'm an online game developer. I've written my game server using c++ on visual studio on windows 10 OS. My hosting machine is run on CentOS 8.

Every time I make a change on server, I transfer all the server code to the hosting via Filezilla , then connect to the server via Putty and navigate to the server folder and rebuild it. Then run it manually on screen(a program in linux based operating systems, that lets you run other programs on background.'this definition might be wrong in some ways')

This is a tiring process and I bet there is a much easier way, only that I don't know about it.

So how can I simplify this process?

1 Answer 1

2

how can I simplify this process?

I'm sure you know about Docker containers at this point, and for some reason not yet disclosed you've decided not to go that route. Ok, we can roll with that.

On the CentOS machine run a very simple nanny.sh script:

#! /usr/bin/env bash

# Keeps the game server running, always, even after an unexpected crash.
while true
do
    /bin/game_server  >> /tmp/out.log  2>> /tmp/err.log
    sleep 1
done

Upon startup, have your game server write its PID to /var/run/game_pid.txt.

Write a very simple deploy_new_server_code.sh script:

#! /usr/bin/env bash

set -e
cd some/where/
git pull
make
cp -p game_server /bin/
kill $(cat /var/run/game_pid.txt)

Now from your development client with the IDE, it's just a matter of $ ssh game-server deploy_new_server_code.sh when you push an edit to GitHub.

You don't need to have a screen ssh session running all the time. But if you do, I imagine you'll have a tail -f of the game log running, so you can see how the newly deployed code behaves.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.