You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Secondly, the following observation currently only applies to Linux. This is because I have not tested or tried to reproduce this behavior on other OSes yet.
I have been using Conf and recently I had a use case in which I had to start a node.js app on OS boot. On Linux, you usually do a systemctl service. In my use case, I wanted my node.js app to start for all users therefore, systemctl has to start the service as a root user. The config values set by the other user via the app were no longer accessible to the app when it was run by root. This means that this is not a permissions related issue and perhaps a planned user separation implemented by Conf?
Is there a way to get around this and have conf set values system-wide?
The text was updated successfully, but these errors were encountered:
I figured this out later. The problem is indeed not with permissions but rather the config file not existing at all for the root user when running the app in the background. Basically, this package conf by default uses user's home directory to create and store configuration file. If the user changes, obviously the home directory changes, hence the unexpected loss of config for your app that might need to run in the background by another user.
The simplest fix for this is that when instantiating conf, you can pass the cwd option to the constructor which will then use your specified location for storing configuration. If your app has a use case like mine, where the config might be created when the app is set up by a human/another user and then your app has to run as a daemon most likely by user root or another special user, your best bet is to specify a system wide config directory that's available to all users via the cwd option. In linux, a standard system-wide config location is the /etc folder.
Remember that your app running as a root means you will have to deal with the sudo shenanigans. If you specify a location at /etc for the cwd option, then all users will either need to be sudoers or have to use sudo on each operation of your app in which conf writes to the configuration file. Otherwise, conf will fail with permission denied error.
P.S @sindresorhus Perhaps this should be mentioned in the Readme? Or at least some more details about the default location of the config file used by conf.
First, thanks for the wonderful open source work.
Secondly, the following observation currently only applies to Linux. This is because I have not tested or tried to reproduce this behavior on other OSes yet.
I have been using Conf and recently I had a use case in which I had to start a node.js app on OS boot. On Linux, you usually do a
systemctl service
. In my use case, I wanted my node.js app to start for all users therefore,systemctl
has to start the service as aroot
user. The config values set by the other user via the app were no longer accessible to the app when it was run by root. This means that this is not a permissions related issue and perhaps a planned user separation implemented by Conf?Is there a way to get around this and have conf set values system-wide?
The text was updated successfully, but these errors were encountered: