tabarra / txAdmin

The official FiveM server management platform used by over 23k servers!
https://txadmin.gg/
MIT License
806 stars 539 forks source link

[Discussion]: Export driven developer API in monitor script #442

Open TasoOneAsia opened 3 years ago

TasoOneAsia commented 3 years ago

Scope

Developer API

Feature Description

Summary Provide a public API for third party resources to trigger methods or fetch useful data within txAdmin.

API Scope This export API should be limited mainly to txAdmin Game Script related functionality defined in the scripts folder. No relaying of data should be done through game scripts as a means of communicating with the txAdmin backend.

Possible Concerns

This API's structure and scope is not final and is open to feedback and comments from contributors and users.

Use Case

We encourage you share any use cases for exports that you may find useful

Additional Info

Proposed Examples:

--- An export returning whether a player has a given txAdmin permission
--- if the player has the 'all_permissions' flag, this function will always
--- return true.
--- @param playerSrc number|string The target player's server ID
--- @param permission string The permission to check against
local function doesPlayerHavePermission(playerSrc, permission)
  return PlayerHasTxPermission(playerSrc, permission)
end
exports('doesPlayerHavePermission', doesPlayerHavePermission)

--- Add an announcement using the in-game menu announcement
--- alerts.
--- @param msg string The announcement message to display
local function addAnnouncement(msg)
  TriggerClientEvent('txAdmin:receiveAnnounce', -1, msg)
end
exports('addAnnouncement', addAnnouncement)

See the following somewhat related issues #179, #436

tabarra commented 5 months ago

@IkonoDim The features you are requesting don't make much sense... you trying to replace the txAdmin ui?!

IkonoDim commented 5 months ago

@tabarra No. But here's a tittle explaination about how I'd use each of these features:

Tfc538 commented 3 months ago

Our goal is to automate server updates, which would significantly streamline our workflow. The plan is to have a test server updated daily and the main server on a weekly basis, each tied to their respective Git branches.

A REST API would facilitate this process, allowing server management through endpoints like https://{server_ip}:{port}/api/v1/shutdownServer, with secure authentication via Bearer Token or User + Password. The challenge lies in ensuring TxAdmin remains operational during updates, which it isn’t if we need to shutdown FxServer in order to do this.

Also we can’t update while FxServer is running as this led to data corruption in earlier attempts.

SeaLife commented 3 months ago

Our goal is to automate server updates, which would significantly streamline our workflow. The plan is to have a test server updated daily and the main server on a weekly basis, each tied to their respective Git branches.

A REST API would facilitate this process, allowing server management through endpoints like https://{server_ip}:{port}/api/v1/shutdownServer, with secure authentication via Bearer Token or User + Password. The challenge lies in ensuring TxAdmin remains operational during updates, which it isn’t if we need to shutdown FxServer in order to do this.

Also we can’t update while FxServer is running as this led to data corruption in earlier attempts.

Hey, so we'r running a Pipeline with Gitlab CI for our scripts which works very well. The "Production" Server is restarted everyday at 10am. The Development-Server is restart every morning at 4am. With TxAdmin if you want to "restart" your Server from external, you could just "stop" the server by the console command "quit" and txAdmin will reboot it. (Is kinda klunky, but it works). We'r doing that on our pre-live server when updating ESX. (because ESX cant be restarted without konsequencens)

But, we'r running some custom pipeline scripts for this and our configuration for something like ESX looks like that:

spec:
  addon-name: es_extended
  directory: esx
  post-commands:
    pre-live:
      - 'quit "Updating ESX Framework"'
  dependencies: []

Bildschirmfoto 2024-05-23 um 10 38 07

So you dont really need a restart API to do a restart if thats the only thing you care about.

Tfc538 commented 3 months ago

Thanks @SeaLife for telling me this! Is there any way to then listen for when the Server is started again?

SeaLife commented 3 months ago

Thanks @SeaLife for telling me this! Is there any way to then listen for when the Server is started again?

Not as far as i know, but you could use a RCON library and check if the server responds to the RCON command as a workaround.

tabarra commented 3 months ago

Hey everyone, an API is finally on the works!

Very soon I'm starting the planning for the API, but no ETA on delivery just yet.
Thank all the 29 people that contributed for the discussion, and thank for your patience!