LuckPerms

LuckPerms

41.4k Downloads

FileWatcher does not trigger for servers that have a symbolic link yaml-storage

TomLewis opened this issue ยท 11 comments

commented

Description

I have a second server that has a symbolic link of the folder yaml-storage for just permissions, that was fixed in 5.1.93, the slight issue is the only way to get the permissions to update on this second server once they are changed on the main server, is to run /lp sync Could we please have FileWatcher watch symbolic links too.

Expected behavior

For FileWatcher to automatically pick up changes to symbolic link folders.

Environment details

  • Server type/version: Paper 1.12.2
  • LuckPerms version: 5.1.93

Any other relevant details

Please do not reply telling me to use MySQL instead I have already had that conversation in #2525

commented

Unfortunately, I don't think this is something Java's file WatchService API supports this - not much I can do about that - sorry!

commented

Generally the path of least resistance would be to use one of the intended methods to sync your LP data such as MySQL, MongoDB, etc. These are designed for syncing data between multiple programs and you should use them as intended.

If you did want to jank-rig your own solution you would need something to run a console command on other servers, something like https://www.spigotmc.org/resources/commandsync.115/

You might actually be able to make use of LP's messaging services to do that but a) at that point just use a database anyway, b) the only one that works without a database is the pluginmsg option which only works when a player is online and c) not 100% sure if the messaging service gets called when LP isnt connected to a database.

I have already had to painfully explain in #2525 and I even wrote at the bottom of my ticket not to reply about MySQL, im more than fully aware of it all yet people still struggle to understand what a workflow is, please do not start this conversation again, Its already been covered in #2525 as linked in the original post.

Now forgetting about MySQL and carrying on with your other ideas, they both sound interesting.
c) I have split storage so users data is in MySQL but specifically just permissions separate as YAML, and yes the messaging system works on bungee.

How would I use the messaging system to do this?

That commandsync just runs commands on all servers on a bungee, so it would require a trigger to run it on the survival which means the file watch event still needs to trigger to run that command.

Alternatively I could just write a bash script that checks if the files been updated and checks it every X time.

commented

Hmm weird, I dont know Java but did some research just to see if I could find a workaround, looks like Symbolic links are transparent unless you specifically look for them, but they have a specific exception if the file is renamed or moved, no mention about checking for if its been updated.

https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/package-summary.html

Many operating systems and file systems support for symbolic links. A symbolic link is a special file that serves as a reference to another file. For the most part, symbolic links are transparent to applications and operations on symbolic links are automatically redirected to the target of the link. Exceptions to this are when a symbolic link is deleted or renamed/moved in which case the link is deleted or removed rather than the target of the link. This package includes support for symbolic links where implementations provide these semantics. File systems may support other types that are semantically close but support for these other types of links is not included in this package.

I had a look on the WatchService API page for dependencies or OS based requirements but turned up nothing.

you can check for a symbolic link http://www.java2s.com/Tutorials/Java/Java_io/0980__Java_nio_Symbolic_Links.htm but I dont think this will help.

So if /lp sync is the right command to run, any way I can get my survival server to trigger this command for my other server? I have a wrapper that accepts console commands as parameters, but I would need to find a way to run a command/script when your file WatchService triggers?

commented

Generally the path of least resistance would be to use one of the intended methods to sync your LP data such as MySQL, MongoDB, etc. These are designed for syncing data between multiple programs and you should use them as intended.

If you did want to jank-rig your own solution you would need something to run a console command on other servers, something like https://www.spigotmc.org/resources/commandsync.115/

You might actually be able to make use of LP's messaging services to do that but a) at that point just use a database anyway, b) the only one that works without a database is the pluginmsg option which only works when a player is online and c) not 100% sure if the messaging service gets called when LP isnt connected to a database.

commented

The messaging service does not trigger for changes detected from configuration files.

Regarding the other replies above: Using a remote database to sync data between servers is a totally valid suggestion - it is literally what it was designed for. The flatfile storage was not designed with this in mind. You're running into problems (and are going to keep running into problems) because what you are trying to do is not particularly sensible or supported.

I have implemented setups like this before - not symlinks, but network shares / Git repos and special deploy scripts to sync config files between servers. It can work very well, but you need to realise that it is not something that plugin authors are going to jump to help you with. It is a non-normal setup, and you are going to run into quirks that you will need to sort yourself.

Back to the original issue - perhaps there is a way to get the WatchService API to play nice with symlinks, but I don't know without researching further. I will happily accept a good PR fixing the problem, but this is a very niche issue, and not a good use of my time at the moment.

commented

The messaging service does not trigger for changes detected from configuration files.

Regarding the other replies above: Using a remote database to sync data between servers is a totally valid suggestion - it is literally what it was designed for. The flatfile storage was not designed with this in mind. You're running into problems (and are going to keep running into problems) because what you are trying to do is not particularly sensible or supported.

I have implemented setups like this before - not symlinks, but network shares / Git repos and special deploy scripts to sync config files between servers. It can work very well, but you need to realise that it is not something that plugin authors are going to jump to help you with. It is a non-normal setup, and you are going to run into quirks that you will need to sort yourself.

Back to the original issue - perhaps there is a way to get the WatchService API to play nice with symlinks, but I don't know without researching further. I will happily accept a good PR fixing the problem, but this is a very niche issue, and not a good use of my time at the moment.

Yup, I know. I have run the MySQL workflow where everything is in MySQL, I've done it. this is why I said it in my initial ticket to not take this ticket off topic because I knew people would go off on it, but nobody will actually read that the workflow is 100x slower.

I explained in the other ticket that the workflow for updating permissions (Not users) saved in MySQL is so poor in comparison to just being able to use VSCode to edit permissions is drastic, I came up with some solutions for improving the web UI to not need to have to login to the console/Minecraft to just push permission changes but these wont be acted on.

99.9% of the time, if you need to make a quick change to a permission, you don't want to have to go through the insane process of Starting Minecraft, waiting for it to load, logging into your server, being BOMBARDED by 100's of people that saw you come online, Run a command to generate a URL, copy that URL into a browser, use the web UI instead of a full Code editor, save your changes, copy that URL go back into game and paste it. (replace logging in with trying to copy a URl in a console thats moving the speed of light lol)

As opposed to the workflow of opening VSCode where all plugin configs are saved, make changes and just upload. Job done.
Its infuriating that nobody can see the difference in workflow here, why is there so much hostility towards me for wanting a better workflow.

Even the self hosted version of the web UI still requires this workflow and cant just connect directly to the MySQL database even though its on the same machine, that would solve it.

I dont know Java but I can ask the question about Symbolic links and the filewatcher in some Java communities to see if someone already has a solution and update this ticket.

I just dont want more people to lecture about converting to MySQL for everything just because thats what you are used to, I know, Ive done it.

commented

There are a few things to point out when making a change to permissions regardless of setup/storage method.

  1. You can always run commands from console. Being the one that can edit server files, I'm very sure you have console access... so I don't see the "insane process" being valid
  2. You can also use commands for permission changes, such as lp group <group> permission set <node> to do a quick addition of permission node (and many others stuff using the relevant commands). You don't have to bring up the editor every time. (and note you don't have to open Minecraft and login in-game, see point 1)
  3. Editor is still a good choice when you want to change many permission nodes. Sure you need to run /lp editor and then lp applyedits <code> (more steps) but the amount of time you are struggling with symbolic link probably already surpassed the simple additional steps of the editor. (and remember that you don't even have to do this if you are just doing small perm modification, see point 2)
commented

There are a few things to point out when making a change to permissions regardless of setup/storage method.

1. You can always run commands from console. Being the one that can edit server files, I'm very sure you have console access... so I don't see the "insane process" being valid

2. You can also use commands for permission changes, such as `lp group <group> permission set <node>` to do a quick addition of permission node (and many others stuff using the relevant commands). You don't have to bring up the editor every time. (and note you don't have to open Minecraft and login in-game, see point 1)

3. Editor is still a good choice when you want to change many permission nodes. Sure you need to run `/lp editor` and then `lp applyedits <code>` (more steps) but the amount of time you are struggling with symbolic link probably already surpassed the simple additional steps of the editor. (and remember that you don't even have to do this if you are just doing small perm modification, see point 2)

Oh yeah, these are a given. At no point would I feel right trying to make permission changes based on just entering a command into the console.
Having a text editor open you can search, copy etc to see a quick overview of that entire rank you are editing is vital, you dont get any of that by just sending a command via console.

Commands in console have its own set of problems.

  1. Feedback is posted with every other message being sent in chat, when you have a busy server with 50+ online this is impossible to keep track you have 0.1 of a second to read that feedback message.
  2. You get no overview of a ranks existing permissions.
  3. So I need to mass add permissions, great now I have to add them one by one.
  4. I want to quickly move a permission from one group to another, I have to run 2 commands.
  5. Where the hell is source control in all of this? At least as a file you have file history with whatever source control people use (Again I will re-iterate my users are MySQL for those that don't read) Im just talking about permissions.

Its not a workflow replacement, at all to having a full text editor.

3\. but the amount of time you are struggling with symbolic link probably already surpassed the simple additional steps of the editor.

Most likley, but once its fixed I don't need to have a special workflow just for permissions, compared to all my other plugins. Like I already said in the other ticket, 80+ plugins that are just all open and available in VSCode.

commented

Quick question: Do you have the base storage folder symlinked or everything inside it?

commented

Quick question: Do you have the base storage folder symlinked or everything inside it?

No. Just the YAML folder, each server needs its own config.yml to tell each server what its called.

I thought of some more issues with MySQL/Commandline.

  • You have to be online to make any changes, you cant just work on anything offline. I found this out today on my laptop when I was out and about and wanted to make some quick changes to permissions, Opened up made them ready for when Im next online. You cant do this with MySQL permissioins (Not users) or Console Command.
commented

There is really no point is giving the downside of one method, just so you can use your own method, it just annoys people. And don't expect people to spend hours just to give/code you the solution lol...