[RELEASE] Multiplatform Auto Restarter/Server Manager v1.0

FiveM Server Manager

A simple yet powerful and useful tool to help you administrate your FiveM server.

Version
Python Requirement

Introduction

This work is registered under the MIT License © Fernando Picoral 2019

This manager does not display anything in-game, it only controls the restarts of the server. To inform players of an upcoming server reboot, you will need to use a server plugin for that. Any ideas are welcome! Please share them in the post on the FiveM Forum. If you run into any bugs, also let me know on the FiveM Forum.

Table of Contents

Features

I will try to keep adding more features and improving the existing ones. For now the available features are:

  • Reboot Handling
  • Close Test Server on Start/Reboot of Main Server
  • Close Browser on Start/Reboot
  • Delete Cache [AVAILABLE IN THE NEXT UPDATE - REALLY SOON]
  • Log of All the Actions
  • Set Priority of Manager and Server
  • Available in English and Portuguese
  • Editable Text Messages (Errors, Warnings, etc)
  • Very Easy to Add Support of Another Language
  • Easy to Use
  • Very Configurable
  • REALLY fast, when it’s not making something, it’s on idle
  • MORE FEATURES ON THE WAY

Any ideas/suggestions are welcome!

Download

Direct Download - FiveM Server Manager v1.rar (29.2 KB)

I recommend using this script made by @Random_0100 to prompt messages to the players in game a few minutes before the restart. Click here to see his release.

Change Log
  • v1.0 - Initial Release
Known Bugs
  • None

From now on it is the README, available as .md and .html on the download folder.

Installation

For any other OS other than Windows (7 or later), see Multipltaform.
You can either use the manager by running the executable or the python script (recommended).

Python Script

First, you need to have python installed on your computer. The recommended version is 3.7 or newer, however, any 3.x version should work just fine. If you don’t have python installed, click here to download the version 3.7.3

You also need to set the path for the config.json file on the manager.py. Open manager.py and around line 9 you will see:

config_path = r"C:/Path/To/config.json"

Put the path to your config.json file there and pay attention not to delete the ‘r’ before the quotes.
You are ready to go! All you need to do is configure the config.json file. See more instructions on that here.

For last but not least, you need to install some python modules. Take a look on one of the first questions on this thread to see how to do that.

After configuring everything, just let the script running and be happy!

Executable

NOT AVAILABLE YET - NEXT UPDATE

If you want to run using the executable, you probably will have to disable your antivirus and Windows Defender. If you don’t feel comfortable doing that, you may do the conversion to .exe on your own using Py2Exe.

With all the antivirus disabled and the config.json properly configured, all you need to do is run the executable from the terminal using the path to the config file as a parameter:

Manager.exe "C:/Path/To/config.json"

Important: remember to use double quotes when the path or the name of the file has spaces. You may only use slashes. Backslashes (\) won’t work.

Since the executable is not the recommended option, no support whatsoever will be provided for bugs involving this option.

Config File

The configuration file config.json is a vital part for the manager. In order to the manager work as intended, the config file must be perfect. Any mistakes will lead to the manager breaking completely. All settings are verified when you first start the manager and, hopefully, if something is not as it’s supposed to be, you will be displayed an error. If you run into a bug which does not show any errors, please inform that on the FiveM forum post.

Default Values

If your file is broken, here are the default values. The explanation for every setting is available below.

{
  "lang": {
    "ui":"en",
    "system":"pt",
    "supported":["en", "pt"],
    "files_paths": {
      "en":"languages/english.json",
      "pt":"languages/portuguese.json"
    }
  },

  "manager": {
    "priority":"normal",
    "title":"Server Manager",
    "engine-path":"engine.bat",
    "readme-path":"README.md"
  },

  "server": {
    "name":"My Server",
    "ip":"localhost:30120",
    "path":"C:/FXServer",
    "cmd-title":"My Server",
    "start-server-cmd-path":"Start_Server.cmd",
    "priority":"realtime",
    "reboots":["06:00", "12:00", "18:00", "00:00"]
  },

  "backup": {
    "backup":true,
    "files":["resources", "server.cfg"],
    "location":"C:/FXServer/Backups",
    "date":["MM","DD","YYYY"],
    "prefix":"Backup - "

  },

  "log": {
    "log":true,
    "prefix":"Server Manager Log - ",
    "date":["MM","DD","YYYY"],
    "type":".log",
    "location":"C:/FXServer/Logs"
  },

  "browser": {
    "image":"chrome.exe",
    "close-on-start":false,
    "close-on-reboot":false
  },

  "test-server": {
    "active":false,
    "name":"My Test Server",
    "ip":"localhost:30121",
    "path":"C:/FXTestServer",
    "close-on-start":false,
    "close-on-reboot":false,
    "cmd-title":"My Test Server"
  }
}

Explanations

Definitions

  • key - a setting
  • block - the sections which the keys are divided by

Lang

Has all the keys related to language.

  • ui - language for the manager and logs. Has to be on the supported array.
  • system - language of your OS
  • supported - array with all the languages. Each one must have a corresponding language file
  • file_paths - dictionary of paths for the languages files

Manager

Controls the manager settings

  • priority - process priority of the manager
  • title - title for the manager’s CMD window
  • engine-path - path for the engine.bat
  • readme-path - path for the readme.md file

Server

One of the most important blocks; controls the information about your server

  • name - your server’s name
  • ip - your server’s ip
  • path - path to the server folder
  • cmd-title - title for the server’s CMD window
  • start-server-cmd-path - path for the Start_Server.cmd file
  • priority - server’s process priority
  • reboots - an array of reboots using the 24h time format. You may have as many reboots as you want in any order

Backup

Information about the files to be saved and where

  • backup - backups happen on every restart. Set it as ‘false’ to turn it off
  • files - an array of files and folders to be saved. Folders are everything that doesn’t have a dot (.) on the name, therefore, don’t use folders with dots on its name. All paths are from the server path on [server][path]
  • location - where you want the backups to be saved
  • date - how do you want the date on the backup’s name. You may change the order but do not change the content of this array
  • prefix - what you want on the backup’s name before the date. Remember to add a space in the end and not to use unsupported characters for files names

Log

Settings about the manager’s logs

  • log - set it to ‘false’ to disable logging
  • prefix - what you want on the log’s name before the date. Remember to add a space in the end and not to use unsupported characters for files names
  • date - how do you want the date on the log’s name. You may change the order but do not change the contenent of this array
  • type - what type of file you want (.log, .txt, .docx)
  • location - where you want the logs to be stored

Browser

Settings to close the browser on start and/or restart

  • image - browser’s executable name. If you are not going to use this, let it as ‘.exe’
  • close-on-start - set it to ‘false’ to disable this function
  • close-on-reboot - set it to ‘false’ to disable this function

Test Server

Settings to handle the test server. If you don’t have one, set [active] as ‘false’ to disable this block

  • active - to disable this whole block, set it to ‘false’
  • name - name of your test server
  • ip - ip of your test server
  • path - path to your test server folder
  • close-on-start - make sure the test server is closed when the main server starts
  • close-on-reboot - make sure the test server is closed on every reboot of the main server
  • cmd-title - title for the test server’s CMD window (future applications)

Multiplatform

The FiveM Server Manager was originally built for Windows but, since it’s a python application, with a few modifications it can work with Linux and Mac. In order to make the manager compatible with MacOS or Linux, you will have to do some modification on the source code.

The only Windows-exclusive feature is the way priority is set, therefore you will need to delete the windows libraries imports, the set_priority(pid=None, priority="normal") method and its calls. You will also need to do some modification on the system calls (os.system) to adapt your OS.

If you create a working version for Linux and/or MacOS, consider sharing it with the community!
Support is only available for the official Windows version.

Help

If you need help with the manager, use the post on the FiveM Forum. I wasn’t able to do a lot of testing so you might encounter some bugs. Please report them so they can be fixed as fast as possible.

Developers

Feel free to contribute to the development of this manager! I didn’t upload it to GitHub (yet). When I do so, the link will be available on the FiveM Forum and the source code.

You may share this application with or without modifications, since you give me the credits and provide a link for the original version.

Search for ‘TODO’ on the source code to take a look at what needs to be fixed/improved.
Avoid using the engine.bat. I did not remove it since it might be useful in the future but, for now, os.system can handle everything with no problems.

10 Likes

Massive release, haven’t read through it yet but damn. You got alot going for this and i hope it has no bugs.

i have all the config settled, but when i ran the Start_Server.cmd, nothing shows up…

Me to same thing is happening. Start the file and server will not start

edited…

You are not supposed to run the Start_Server.cmd, this file will be called from the manager.

If you read the README (or the post, it’s the same thing) you will see how properly start the manager (in Instalation>Python Script)

@hiubeo

Hello,
When I restart my server after putting the start command in the server.cfg file…I get the following error:

Found new resource ServerManager in M:/FXServer\cfx-server-data-master/resources//ServerManager
Resource loading for ServerManager failed:
Could not open resource metadata file M:/FXServer\cfx-server-data-master/resources//ServerManager/__resource.lua.

Am I missing any files? I downloaded the .rar file and followed the instructions…but can’t seem to locate the .lua file(s).

I also noticed the path has 2 // (resources//ServerManager) - which file do I need to edit to fix this?

Any help would be appreciated.

Thanks!

This is not a resource and should not be put in your server files. All you have to do is configurate it run “manager.py”.

GUYS, READ THE POST/README, ALL THE QUESTIONS SO FAR WERE ALREADY ANSWER ON THE POST

My apologies Fernando_Picoral - I was looking at 2-3 different mod installations at the same time. Read one install mod as the Server Manager.

Thanks for the info though.

  • Changed .py to:

config_path = r"D:/FiveM3/config.json"

Tried single ’ too

  • Changed config.json to

{
“lang”: {
“ui”:“en”,
“system”:“pt”,
“supported”:[“en”, “pt”],
“files_paths”: {
“en”:“languages/english.json”,
“pt”:“languages/portuguese.json”
}
},

“manager”: {
“priority”:“normal”,
“title”:“Server Manager”,
“engine-path”:“engine.bat”,
“readme-path”:“README.md”
},

“server”: {
“name”:“Nieuwstad RP”,
“ip”:“0.0.0.0:30120”,
“path”:“D:/FiveM3”,
“cmd-title”:“Nieuwstad RP”,
“start-server-cmd-path”:“Start_Server.cmd”,
“priority”:“realtime”,
“reboots”:[“06:00”, “12:00”, “18:00”, “00:00”]
},

“backup”: {
“backup”:true,
“files”:[“resources”, “server.cfg”],
“location”:“D:/FiveM3/Backups”,
“date”:[“MM”,“DD”,“YYYY”],
“prefix”:"Backup - "

},

“log”: {
“log”:true,
“prefix”:“Server Manager Log - “,
“date”:[“MM”,“DD”,“YYYY”],
“type”:”.log”,
“location”:“D:/FiveM3/Logs”
},

“browser”: {
“image”:“firefox.exe”,
“close-on-start”:false,
“close-on-reboot”:false
},

Localhost does not work, external ip does not work either.

  • Added new logs and backup folder.

When I open manager.py, it closes itself within 1 second.
Does it only work with chrome.exe?

Maybe you can add a option to send a message X mins before the reboot?

Thanks.

That would be a whole new resource, this is just a script. For that you need to download a plugin (I put a suggestion for that under the download section).

An error is occuring then. Instead of running it normally, start it using CMD so you can see the error.

To do that, open CMD, and type C:\Path\To\manager.py

If you see an error message, please send it here.

I started to get this error all of a sudden, after fixing another issue.

Python Version: Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32 (I didn’t see anywhere if I needed 32 or 64 bit version)

M:\ServerManager>manager.py
Traceback (most recent call last):
File “M:\ServerManager\manager.py”, line 623, in
if load_config(): #Returns true when no errors occur
File “M:\ServerManager\manager.py”, line 38, in load_config
config = jload(file)
File “L:\Python\lib\json_init_.py”, line 296, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File “L:\Python\lib\json_init_.py”, line 348, in loads
return _default_decoder.decode(s)
File “L:\Python\lib\json\decoder.py”, line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “L:\Python\lib\json\decoder.py”, line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Invalid \escape: line 32 column 27 (char 708)

I’m also getting an error.

Traceback (most recent call last):
  File "D:\Programs\FiveM_Server_Manager_v1\manager.py", line 15, in <module>
    import win32gui,win32process,signal,psutil
ModuleNotFoundError: No module named 'win32gui'

DoJoMan18 -

I had that issue…I installed https://github.com/mhammond/pywin32/releases and it went away.

How to use it with your release?

ive currently got this issue after i did everything how it was stated
i went to the command and did this: `C:\Path\To\manager.py (correct path of course)

print(f"[CONFIG.JSON CRITICAL ERROR] - ‘{key}’ missing on language settings.")

Are you on windows? If yes, do the following:

  1. Open the CMD
  2. Type pip install win32gui and hit enter
    2.1) If it returns and error, try using py pip install win32gui

You should be ready to go!

This is problem parsing the json config file. Are you using \ instead of / on the config_path variable?