Commit 3624e3dd authored by Brendan Long's avatar Brendan Long

Make --watch a command-line option.

parent eb480247
......@@ -22,7 +22,7 @@ There is also a `clean.sh` script if you need it for some reason, but usually tu
./src/server -c config/config.json
You should now be able to discover the server with your client.
You should now be able to discover the server with your client. Adding `-w` will make the server watch the config file for changes and send UIListingUpdate events when the RUI list changes. You can use `--help` to list all options.
On Fedora, you may need to disable the firewall:
......
......@@ -166,7 +166,6 @@ public class RUI.ConfigFileReader {
stdout.printf("Watching %s\n", file.get_path());
file_monitor = file.monitor(FileMonitorFlags.NONE);
file_monitor.changed.connect(on_config_file_changed);
parse_config_file();
}
private void on_config_file_changed(File file, File? other_file,
......
......@@ -25,6 +25,7 @@
*/
static string? config_file = null;
static bool debug = false;
static bool watch = false;
static const OptionEntry[] options = {
{ "config-file", 'c', 0, OptionArg.FILENAME, ref config_file,
......@@ -32,6 +33,8 @@ static const OptionEntry[] options = {
"[file]" },
{ "debug", 'd', 0, OptionArg.NONE, ref debug,
"Print debug messages to the console", null },
{ "watch", 'w', 0, OptionArg.NONE, ref watch,
"Watch the config file and send UIListingUpdate events", null },
{ null }
};
......@@ -58,7 +61,10 @@ internal static int main(string[] args) {
RUI.ConfigFileReader config;
try {
config = new RUI.ConfigFileReader(config_file);
config.watch_config_file();
config.parse_config_file();
if (watch) {
config.watch_config_file();
}
} catch (Error e) {
stderr.printf("Error reading config file %s: %s\n", config_file,
e.message);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment