|
51 | 51 | (defn init-dynamic-prompt-watcher [opts registry-updated markdown-tool-updated]
|
52 | 52 | (let [change-events-channel (async/chan)
|
53 | 53 | debounced (debounce-by change-events-channel content)]
|
| 54 | + (doseq [container (docker/containers {:label ["com.docker.desktop.extension=true" |
| 55 | + "com.docker.mcp.watch-service=true"] |
| 56 | + :name ["com.docker.mcp.watch-service"]})] |
| 57 | + (logger/info "shutting down previous vonwig/inotifywait container" (:name container)) |
| 58 | + (try |
| 59 | + (docker/stop-container container) |
| 60 | + (docker/kill-container container) |
| 61 | + (catch Throwable _ |
| 62 | + (logger/warn "unable to kill conainer " (:Id container))))) |
54 | 63 | ;; debounce the change event channel
|
55 | 64 | (async/go-loop
|
56 | 65 | [evt (async/<! debounced)]
|
|
60 | 69 | :unknown)
|
61 | 70 | (recur (async/<! debounced)))
|
62 | 71 | ;; watch filesystem
|
63 |
| - (let [{x :container} |
64 |
| - (docker/run-streaming-function-with-no-stdin |
65 |
| - {:image "vonwig/inotifywait:latest" |
66 |
| - :labels {"com.docker.desktop.service" "true"} |
67 |
| - :volumes ["docker-prompts:/prompts"] |
68 |
| - :command ["-e" "create" "-e" "modify" "-e" "delete" "-q" "-m" "/prompts"]} |
69 |
| - (fn [line] |
70 |
| - (let [[_dir _event f] (string/split line #"\s+")] |
71 |
| - (async/put! |
72 |
| - change-events-channel |
73 |
| - (cond |
74 |
| - (= f "registry.yaml") |
75 |
| - {:opts opts :f f :type :registry} |
76 |
| - (string/ends-with? f ".md") |
77 |
| - {:opts opts :f f :type :markdown} |
78 |
| - :else |
79 |
| - {})))))] |
80 |
| - (shutdown/schedule-container-shutdown |
81 |
| - (fn [] |
82 |
| - (logger/info "inotifywait shutting down") |
83 |
| - (docker/kill-container x) |
84 |
| - (docker/delete x)))))) |
| 72 | + (try |
| 73 | + (let [{x :container} |
| 74 | + (docker/run-streaming-function-with-no-stdin |
| 75 | + {:image "vonwig/inotifywait:latest" |
| 76 | + :labels {"com.docker.desktop.extension" "true" |
| 77 | + "com.docker.mcp.watch-service" "true" |
| 78 | + "com.docker.compose.project" "docker_labs-ai-tools-for-devs-desktop-extension" |
| 79 | + "com.docker.compose.service" "registry-watcher"} |
| 80 | + :volumes ["docker-prompts:/prompts"] |
| 81 | + :command ["-e" "create" "-e" "modify" "-e" "delete" "-q" "-m" "/prompts"]} |
| 82 | + (fn [line] |
| 83 | + (let [[_dir _event f] (string/split line #"\s+")] |
| 84 | + (async/put! |
| 85 | + change-events-channel |
| 86 | + (cond |
| 87 | + (= f "registry.yaml") |
| 88 | + {:opts opts :f f :type :registry} |
| 89 | + (string/ends-with? f ".md") |
| 90 | + {:opts opts :f f :type :markdown} |
| 91 | + :else |
| 92 | + {})))))] |
| 93 | + (shutdown/schedule-container-shutdown |
| 94 | + (fn [] |
| 95 | + (logger/info "inotifywait shutting down") |
| 96 | + (docker/kill-container x) |
| 97 | + (docker/delete x)))) |
| 98 | + (catch Throwable t |
| 99 | + (logger/error "unable to start registry.yaml watcher" t))))) |
85 | 100 |
|
86 | 101 | (comment
|
87 | 102 | (repl/setup-stdout-logger)
|
|
0 commit comments