[DAEMON-57] appcd: Add support to config handler to change settings at runtime
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Medium |
Status | Resolved |
Resolution | Fixed |
Resolution Date | 2017-05-09T19:52:04.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Appc Daemon 1.0.0 |
Components | appcd-config, appcd-config-service |
Labels | n/a |
Reporter | Chris Barber |
Assignee | Chris Barber |
Created | 2017-02-27T17:05:22.000+0000 |
Updated | 2017-10-26T03:07:25.000+0000 |
Description
The config handler currently only returns the config. The handler should also support a "data" payload to change the daemon's config at runtime.
Note that only a single config setting can be changed per call. Use the path to determine what is being changed. HTTP methods can be used to determine how the key should be changed. The handler returns the new value. Use the status code to determine if successful.
The appcd CLI is responsible for persisting the settings to the user's config file
~/.appcelerator/appcd/config.json
. The daemon does not modify the config file. The appcd CLI will validate the config change, then persist it to disk. After that, it will check if the daemon is running and attempt to change it at runtime. If the daemon is not running or it is running and the setting is changeable during runtime, then everything succeeds. If the daemon is running and the change is rejected, then the CLI will alert the user that the daemon must be restarted for the setting to take effect. If the CLI as a TTY, it can prompt to restart the daemon. Note that the CLI should also support a \-\-no\-prompt
flag and a \-\-auto\-restart
flag.
Examples:
Getting a value:
appcd exec /appcd/config/analytics/enabled
appcd exec /appcd/config/analytics/enabled '{ "action": "get" }'
appcd exec /appcd/config '{ "action": "get", "key": "/analytics/enabled" }'
appcd exec /appcd/config '{ "action": "get", "key": "analytics.enabled" }'
Setting a value:
appcd exec /appcd/config '{ "action": "set", "key": "analytics.enabled", "value": true }'
appcd exec /appcd/config/analytics/enabled '{ "action": "set", "value": true }'
Deleting a value:
appcd exec /appcd/config '{ "action": "delete", "key": "analytics.enabled" }'
appcd exec /appcd/config/analytics/enabled '{ "action": "delete" }'
Array examples:
appcd exec /appcd/config '{ "action": "set", "key": "foo", "value": ["bar", "baz"] }'
Delete will remove the entire value.
appcd exec /appcd/config '{ "action": "delete", "key": "foo" }'
https://github.com/appcelerator/appc-daemon/pull/11