djdv / go-filesystem-utils

ISC License
10 stars 2 forks source link

Integrate with system service managers #34

Open djdv opened 1 year ago

djdv commented 1 year ago

Closes: https://github.com/djdv/go-filesystem-utils/issues/21 This is a port of the code mentioned in #21. It works, but I'm likely going to make a fork of the service pkg. Some fixes need to be incorporated, and the API could benefit from change.

Particularly, the handling of system specific options is done via a map[string]interface{}, where the map keys are not exported and the values circumvent the type system. I think this could be changed so that the Config struct simply has different struct members based on which OS is being built for. This would eliminate the chance of using the wrong key or value type at compile time, rather than depending on reflection and possibly having unexpected behaviour.

In addition, some of the service files are generated from text templates. Like the launchd plist and systemd unit files. It would be better if these utilized libraries which generated those files for us, through some standard and maintained API built specifically for those systems. This would make it easy to stay in sync with any changes, while also bolstering assurance that the files generated are well formed and standard compliant.