Search code examples
linuxunixservicelinux-kernelcommand

How to load a new configuration file?


I'm wondering how to load a new configuration file for a service with and without changing its process ID with writing commands?

I couldn't find a simple answer


Solution

  • Here is a simple way to realise it.

    Firstly, you need a .ini file, which is your configuration file.

    Secondly, edit your code and adding a new class or structure to save the settings, every time it start, the configuration file will be loaded and using the settings to run.

    Then, your code need one more thing : a command to reload configuration file, which will change the state of the settings class/structure.

    What's more, for a service, you need to consider that when using the command, maybe it's best to stop something for a little momment to reload new settings. For example, if it's a game, you need to stop some specific service for players in a while.

    In a word, without kill the process, the process ID will not change.