Skip to content

Commit 4b2e86a

Browse files
committed
node/gnd: Deploy all subgraphs on startup
1 parent bdec95e commit 4b2e86a

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

node/src/bin/dev.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use graph::{
1313
};
1414
use graph_core::polling_monitor::ipfs_service;
1515
use graph_node::{
16+
dev::watcher,
1617
dev::watcher::{parse_manifest_args, watch_subgraphs},
1718
launcher,
1819
opt::Opt,
@@ -142,8 +143,8 @@ fn build_args(dev_opt: &DevOpt, db_url: &str) -> Result<Opt> {
142143

143144
opt.http_port = dev_opt.http_port;
144145
opt.admin_port = dev_opt.admin_port;
145-
opt.metrics_port = dev_opt.admin_port;
146-
opt.index_node_port = dev_opt.admin_port;
146+
opt.metrics_port = dev_opt.metrics_port;
147+
opt.index_node_port = dev_opt.index_node_port;
147148

148149
Ok(opt)
149150
}
@@ -152,7 +153,7 @@ async fn run_graph_node(
152153
logger: &Logger,
153154
opt: Opt,
154155
link_resolver: Arc<dyn LinkResolver>,
155-
subgraph_updates_channel: Option<mpsc::Receiver<(DeploymentHash, SubgraphName)>>,
156+
subgraph_updates_channel: mpsc::Receiver<(DeploymentHash, SubgraphName)>,
156157
) -> Result<()> {
157158
let env_vars = Arc::new(EnvVars::from_env().context("Failed to load environment variables")?);
158159

@@ -173,7 +174,7 @@ async fn run_graph_node(
173174
env_vars,
174175
ipfs_service,
175176
link_resolver,
176-
subgraph_updates_channel,
177+
Some(subgraph_updates_channel),
177178
)
178179
.await;
179180
Ok(())
@@ -235,14 +236,22 @@ async fn main() -> Result<()> {
235236
parse_manifest_args(dev_opt.manifests, dev_opt.sources, &logger)?;
236237
let file_link_resolver = Arc::new(FileLinkResolver::new(None, source_subgraph_aliases.clone()));
237238

238-
let (tx, rx) = dev_opt.watch.then(|| mpsc::channel(1)).unzip();
239+
let (tx, rx) = mpsc::channel(1);
239240

240241
let logger_clone = logger.clone();
241242
graph::spawn(async move {
242243
let _ = run_graph_node(&logger_clone, opt, file_link_resolver, rx).await;
243244
});
244245

245-
if let Some(tx) = tx {
246+
if let Err(e) =
247+
watcher::deploy_all_subgraphs(&logger, &manifests_paths, &source_subgraph_aliases, &tx)
248+
.await
249+
{
250+
error!(logger, "Error deploying subgraphs"; "error" => e.to_string());
251+
std::process::exit(1);
252+
}
253+
254+
if dev_opt.watch {
246255
graph::spawn_blocking(async move {
247256
if let Err(e) = watch_subgraphs(
248257
&logger,

node/src/dev/watcher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ fn is_relevant_event(event: &Event, watched_dirs: Vec<PathBuf>, exclusion_set: &
255255
}
256256

257257
/// Redeploys all subgraphs in the order it appears in the manifests_paths
258-
async fn deploy_all_subgraphs(
258+
pub async fn deploy_all_subgraphs(
259259
logger: &Logger,
260260
manifests_paths: &Vec<PathBuf>,
261261
source_subgraph_aliases: &HashMap<String, PathBuf>,

0 commit comments

Comments
 (0)