-
Notifications
You must be signed in to change notification settings - Fork 315
/
lib.rs
167 lines (157 loc) · 4.87 KB
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
// Copyright (c) 2016 Chef Software Inc. and/or applicable contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Habitat helps you build, manage, and run applications - on bare metal, in the cloud, and in
//! containers. You can [read more about it on the website](https://www.habitat.sh/).
//!
//! Habitat contains two main components:
//!
//! * `hab-plan-build`, takes a plan ('plan.sh'), a description of how to build a piece of software,
//! written in [bash](http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html), which produces an atomic
//! package.
//! * `hab-sup`, a run-time executable that knows how to download, install, serve, and
//! manage services defined in packages.
//!
//! # hab-plan-build
//!
//! The documentation for hab-plan-build is generated automatically from the script itself, [and
//! can be found here](hab-plan-build/hab-plan-build.html). You can find it in the source tree at
//! `components/plan-build`.
//!
//! # The Supervisor
//!
//! The Supervisor is primarily utilized through the `hab-sup` command; it can also be used from
//! within Rust as a library. This documentation covers both uses; it explains how things are used
//! from the command line in close proximity to the documentation of the library itself. A few
//! useful starting points:
//!
//! * [The Habitat Command Line Reference](command)
//! * [The Habitat Supervisor Sidecar; http interface to promises](sidecar)
extern crate actix;
extern crate actix_web;
extern crate ansi_term;
#[macro_use]
extern crate bitflags;
extern crate byteorder;
#[cfg(target_os = "linux")]
extern crate caps;
extern crate clap;
#[cfg(windows)]
extern crate ctrlc;
#[macro_use]
extern crate features;
#[macro_use]
extern crate futures;
extern crate glob;
extern crate hab;
extern crate habitat_butterfly as butterfly;
#[cfg_attr(test, macro_use)]
extern crate habitat_common as common;
#[macro_use]
extern crate habitat_core as hcore;
extern crate habitat_api_client as api_client;
extern crate habitat_eventsrv_client as eventsrv_client;
extern crate habitat_launcher_client as launcher_client;
extern crate habitat_sup_protocol as protocol;
extern crate handlebars;
#[macro_use]
extern crate lazy_static;
extern crate libc;
#[macro_use]
extern crate log;
extern crate notify;
extern crate num_cpus;
extern crate prost;
extern crate protobuf;
extern crate rand;
extern crate regex;
extern crate rustls;
extern crate serde;
#[macro_use]
extern crate serde_derive;
#[allow(unused_imports)]
#[macro_use]
extern crate serde_json;
extern crate serde_transcode;
extern crate serde_yaml;
extern crate tempfile;
extern crate time as time_crate;
extern crate tokio;
extern crate tokio_codec;
#[macro_use]
extern crate tokio_core;
extern crate toml;
extern crate url;
extern crate valico;
#[cfg(test)]
extern crate json;
#[macro_export]
/// Creates a new SupError, embedding the current file name, line number, column, and module path.
macro_rules! sup_error {
($p:expr) => {{
use $crate::error::SupError;
SupError::new($p, LOGKEY, file!(), line!(), column!())
}};
}
#[cfg(test)]
#[macro_use]
pub mod cli_test_helpers;
pub mod census;
pub mod cli;
pub mod command;
pub mod config;
pub mod ctl_gateway;
pub mod error;
pub mod fs;
pub mod http_gateway;
pub mod manager;
mod sys;
pub mod templating;
#[cfg(test)]
pub mod test_helpers;
pub mod util;
use std::env;
use std::path::PathBuf;
lazy_static! {
pub static ref PROGRAM_NAME: String = {
let arg0 = env::args().next().map(|p| PathBuf::from(p));
arg0.as_ref()
.and_then(|p| p.file_stem())
.and_then(|p| p.to_str())
.unwrap()
.to_string()
};
}
/// List enables printing out the list features which can be dynamically enabled
/// TestExit enables triggering an abrupt exit to simulate failures
/// TestBootFail exits with a fatal error before even calling boot()
/// Search for feat::is_enabled(feat::FeatureName) to learn more
features! {
pub mod feat {
const List = 0b00000001,
const TestExit = 0b00000010,
const TestBootFail = 0b00000100,
const RedactHTTP = 0b00001000,
const IgnoreSignals = 0b00010000
}
}
pub const PRODUCT: &'static str = "hab-sup";
pub const VERSION: &'static str = include_str!(concat!(env!("OUT_DIR"), "/VERSION"));
#[derive(Copy, Clone)]
pub enum ShutdownReason {
Departed,
LauncherStopping,
PkgUpdating,
Signal,
SvcStopCmd,
}