risingwave_cmd/
lib.rs

1// Copyright 2025 RisingWave Labs
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use risingwave_compactor::CompactorOpts;
16use risingwave_compute::ComputeNodeOpts;
17use risingwave_ctl::CliOpts as CtlOpts;
18use risingwave_frontend::FrontendOpts;
19use risingwave_meta_node::MetaNodeOpts;
20use risingwave_rt::{LoggerSettings, init_risingwave_logger, main_okk};
21
22/// Define the `main` function for a component.
23#[macro_export]
24macro_rules! main {
25    ($component:ident) => {
26        risingwave_common::enable_jemalloc!();
27
28        fn main() {
29            let opts = clap::Parser::parse();
30            $crate::$component(opts);
31        }
32    };
33}
34
35risingwave_batch_executors::enable!();
36risingwave_expr_impl::enable!();
37
38// Entry point functions.
39
40pub fn compute(opts: ComputeNodeOpts) -> ! {
41    init_risingwave_logger(LoggerSettings::from_opts(&opts));
42    main_okk(|shutdown| risingwave_compute::start(opts, shutdown));
43}
44
45pub fn meta(opts: MetaNodeOpts) -> ! {
46    init_risingwave_logger(LoggerSettings::from_opts(&opts));
47    main_okk(|shutdown| risingwave_meta_node::start(opts, shutdown));
48}
49
50pub fn frontend(opts: FrontendOpts) -> ! {
51    init_risingwave_logger(LoggerSettings::from_opts(&opts));
52    main_okk(|shutdown| risingwave_frontend::start(opts, shutdown));
53}
54
55pub fn compactor(opts: CompactorOpts) -> ! {
56    init_risingwave_logger(LoggerSettings::from_opts(&opts));
57    main_okk(|shutdown| risingwave_compactor::start(opts, shutdown));
58}
59
60pub fn ctl(opts: CtlOpts) -> ! {
61    init_risingwave_logger(LoggerSettings::new("ctl").stderr(true));
62    main_okk(|shutdown| risingwave_ctl::start(opts, shutdown));
63}