Skip to content

Commit

Permalink
Add ability to set query by env var
Browse files Browse the repository at this point in the history
  • Loading branch information
mwylde committed Jun 18, 2024
1 parent deccc9f commit 58d39aa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
7 changes: 7 additions & 0 deletions crates/arroyo-rpc/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ pub struct Config {
/// process with a non-standard port.
compiler_endpoint: Option<Url>,

/// Supplies the default query for `arroyo run`; otherwise the query is read from the command
/// line or from stdin
pub query: Option<String>,

/// Controls whether preview pipelines should have sinks enabled
#[serde(default)]
pub sinks_in_preview: bool,
Expand Down Expand Up @@ -274,6 +278,9 @@ pub struct ApiConfig {

/// The HTTP port for the API service
pub http_port: u16,

/// The HTTP port for the API service in run mode; defaults to a random port
pub run_http_port: Option<u16>,
}

#[derive(Debug, Deserialize, Serialize, Clone)]
Expand Down
13 changes: 10 additions & 3 deletions crates/arroyo/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use anyhow::bail;
use arroyo_openapi::types::{Pipeline, PipelinePatch, PipelinePost, StopType, ValidateQueryPost};
use arroyo_openapi::Client;
use arroyo_rpc::config;
use arroyo_rpc::config::{DatabaseType, DefaultSink, Scheduler};
use arroyo_rpc::config::{config, DatabaseType, DefaultSink, Scheduler};
use arroyo_server_common::log_event;
use arroyo_server_common::shutdown::{Shutdown, ShutdownHandler, SignalBehavior};
use async_trait::async_trait;
Expand Down Expand Up @@ -197,7 +197,10 @@ async fn run_pipeline(
pub async fn run(args: RunArgs) {
let _guard = arroyo_server_common::init_logging("pipeline");

let query = std::io::read_to_string(args.query).unwrap();
let query = match config().query.clone() {
Some(query) => query,
None => std::io::read_to_string(args.query).unwrap(),
};

let mut shutdown = Shutdown::new("pipeline", SignalBehavior::Handle);

Expand All @@ -209,7 +212,11 @@ pub async fn run(args: RunArgs) {
c.database.r#type = DatabaseType::Sqlite;
c.database.sqlite.path = db_path.clone();

c.api.http_port = 0;
if let Some(port) = c.api.run_http_port {
c.api.http_port = port;
} else {
c.api.http_port = 0;
}
c.controller.rpc_port = 0;
c.controller.scheduler = Scheduler::Process;

Expand Down
12 changes: 5 additions & 7 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ RUN apt-get update && \

COPY --from=builder /arroyo ./

ENV PRODUCTION=true \
ASSET_DIR="/app/dist" \
INSTALL_RUSTC=true \
INSTALL_CLANG=true
ENV INSTALL_RUSTC=true \
INSTALL_CLANG=true \
ARROYO__API__RUN_HTTP_PORT=8000

EXPOSE 8000
ENTRYPOINT [ "/app/arroyo" ]
Expand All @@ -69,10 +68,9 @@ WORKDIR /app
RUN apt-get update && \
apt-get -y install libsasl2-2 ca-certificates curl pkg-config

COPY --from=builder /arroyo ./
ENV ARROYO__API__RUN_HTTP_PORT=8000

ENV PRODUCTION=true \
ASSET_DIR="/app/dist"
COPY --from=builder /arroyo ./

EXPOSE 8000
ENTRYPOINT [ "/app/arroyo" ]

0 comments on commit 58d39aa

Please sign in to comment.