Keep server running on VPS (Ubuntu 16.04)
-
- A semi-regular
- Posts: 28
- https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
- Joined: Thu Jul 02, 2015 2:54 pm
- Contact:
Keep server running on VPS (Ubuntu 16.04)
I am currently running a single core Ubuntu 16.04 VPS and put my fivem gtav server on there. It seems the only way I can keep the server running is if I am signed into my VPS via SSH PuTTy and when I close out of PuTTy my server shuts down. I'd like to figure out how the server can remain running even when I am not signed into the vps constantly.
Re: Keep server running on VPS (Ubuntu 16.04)
The "screen" program is what you'd want to use, or "tmux"
Re: Keep server running on VPS (Ubuntu 16.04)
You can use screen for this, runs the process in its own 'container' that stays running when you disconnect via ssh.
First make sure screen is installed with
Start up the server with its start up script using
*You can change Screenname to a name you want
To attach the screen, to view it for potential logs or to view it When done, detach from the screen with “Ctrl-a” “d”
First make sure screen is installed with
Code: Select all
sudo apt-get install screen
Code: Select all
screen -S Screenname -d -m /path/to/running/script.extension
To attach the screen, to view it for potential logs or to view it
Code: Select all
screen -R Screenname
-
- A semi-regular
- Posts: 28
- Joined: Thu Jul 02, 2015 2:54 pm
- Contact:
Re: Keep server running on VPS (Ubuntu 16.04)
As I was waiting for a response I actually found this article here and now my /etc/rc.local now looks like the following:
So with that everytime my VPS is rebooted my FiveM GTA V Server boots up as well but ran into a few issues maybe you can help me solve?
Code: Select all
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
cd /home/server/server-data
bash /home/server/run.sh +exec server.cfg
exit 0
- Not sure how to get back to server console if I need to run convars or check logs.
- In order to stop, start, restart the FiveM GTA V Server I need to reboot the VPS machine. Is it possible to create bash scripts to just restart the server instead of having to do the entire machine every single time?!
Re: Keep server running on VPS (Ubuntu 16.04)
My instructions with a screen will allow you to attach the screen to input commands if that '/home/server/run.sh' script allows user input
-
- A semi-regular
- Posts: 28
- Joined: Thu Jul 02, 2015 2:54 pm
- Contact:
Re: Keep server running on VPS (Ubuntu 16.04)
Awesome, got a screen so the server console is on my "server" screen but still run into my issue, how can I create bash script(s) so I can run something that will restart, stop or start just the GTA V server. I am a bit new to the VPS thing if you couldn't tellrushy wrote:My instructions with a screen will allow you to attach the screen to input commands if that '/home/server/run.sh' script allows user input
Re: Keep server running on VPS (Ubuntu 16.04)
From what I could tell from the FiveM wiki, the server itself does not have any restart, or Quit commands.lowheartrate wrote:Awesome, got a screen so the server console is on my "server" screen but still run into my issue, how can I create bash script(s) so I can run something that will restart, stop or start just the GTA V server. I am a bit new to the VPS thing if you couldn't tellrushy wrote:My instructions with a screen will allow you to attach the screen to input commands if that '/home/server/run.sh' script allows user input
If that is correct:
What you would have to do is
1. Create 'startup script that has the normal screen start.
2. One that kills the screen with the command 'screen -X -S Screenname quit' - Terminating a screen kills the application running within
3. One that 'restarts' - combines the kill command and a screen start afterwards
In my following example I called my screen GTAVScreen, change to what you would like.
#1 (Change to what you used when you manually created the screen, below is just an example):
Code: Select all
#!/bin/sh
screen -S GTAVScreen -d -m /home/server/run.sh +exec server.cfg
Code: Select all
#!/bin/sh
screen -X -S GTAVScreen quit
Code: Select all
#!/bin/sh
screen -X -S GTAVScreen quit
sleep 10
screen -S GTAVScreen -d -m /home/server/run.sh +exec server.cfg
Of course you will need to chmod them all to make it executable with chmod +x
eg If I made a start.sh script, I would issue chmod +x start.sh (from within the same directory)
To activate them you would use ./start.sh or use the whole path if outside the directory
-
- A semi-regular
- Posts: 28
- Joined: Thu Jul 02, 2015 2:54 pm
- Contact:
Re: Keep server running on VPS (Ubuntu 16.04)
Awesome! Thanks so much for the help got the scripts going and they're working great! thank you thank you thank you