feat: -s flag for showing self when conterainerised
This commit is contained in:
@@ -73,6 +73,7 @@ Available command line arguments
|
|||||||
|```-r```| show raw logs, by default oxker will remove ANSI formatting (conflicts with -c) |
|
|```-r```| show raw logs, by default oxker will remove ANSI formatting (conflicts with -c) |
|
||||||
|```-c```| attempt to color the logs (conflicts with -r) |
|
|```-c```| attempt to color the logs (conflicts with -r) |
|
||||||
|```-t```| remove timestamps from each log entry |
|
|```-t```| remove timestamps from each log entry |
|
||||||
|
|```-s```| if running via docker, will show the oxker container |
|
||||||
|```-g```| no tui, basically a pointless debugging mode, for now |
|
|```-g```| no tui, basically a pointless debugging mode, for now |
|
||||||
|
|
||||||
## Build step
|
## Build step
|
||||||
|
|||||||
@@ -55,5 +55,6 @@ FROM alpine:latest AS runtime
|
|||||||
COPY --from=builder /oxker /usr/local/bin
|
COPY --from=builder /oxker /usr/local/bin
|
||||||
COPY ./containerised/start_oxker.sh ./
|
COPY ./containerised/start_oxker.sh ./
|
||||||
|
|
||||||
# Run the application, this is used in the application itself, to stop itself show when running from a docker container, so DO NOT EDIT
|
# Run the application
|
||||||
|
# this is used in the application itself, to stop itself show when running from a docker container, so DO NOT EDIT
|
||||||
ENTRYPOINT [ "./start_oxker.sh"]
|
ENTRYPOINT [ "./start_oxker.sh"]
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ FROM alpine:latest AS runtime
|
|||||||
COPY ./target/x86_64-unknown-linux-musl/release/oxker /usr/local/bin
|
COPY ./target/x86_64-unknown-linux-musl/release/oxker /usr/local/bin
|
||||||
COPY ./containerised/start_oxker.sh ./
|
COPY ./containerised/start_oxker.sh ./
|
||||||
|
|
||||||
# Run the application, this is used in the application itself, to stop itself show when running from a docker container, so DO NOT EDIT
|
# Run the application
|
||||||
|
# this is used in the application itself, to stop itself show when running from a docker container, so DO NOT EDIT
|
||||||
ENTRYPOINT [ "./start_oxker.sh"]
|
ENTRYPOINT [ "./start_oxker.sh"]
|
||||||
|
|
||||||
## One liner to build musl program, build docker image, then execute the image
|
## One liner to build musl program, build docker image, then execute the image
|
||||||
|
|||||||
+13
-11
@@ -51,14 +51,14 @@ impl Binate {
|
|||||||
|
|
||||||
pub struct DockerData {
|
pub struct DockerData {
|
||||||
app_data: Arc<Mutex<AppData>>,
|
app_data: Arc<Mutex<AppData>>,
|
||||||
|
args: CliArgs,
|
||||||
|
binate: Binate,
|
||||||
docker: Arc<Docker>,
|
docker: Arc<Docker>,
|
||||||
gui_state: Arc<Mutex<GuiState>>,
|
gui_state: Arc<Mutex<GuiState>>,
|
||||||
initialised: bool,
|
initialised: bool,
|
||||||
is_running: Arc<AtomicBool>,
|
is_running: Arc<AtomicBool>,
|
||||||
receiver: Receiver<DockerMessage>,
|
receiver: Receiver<DockerMessage>,
|
||||||
spawns: Arc<Mutex<HashMap<SpawnId, JoinHandle<()>>>>,
|
spawns: Arc<Mutex<HashMap<SpawnId, JoinHandle<()>>>>,
|
||||||
timestamps: bool,
|
|
||||||
binate: Binate,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DockerData {
|
impl DockerData {
|
||||||
@@ -173,7 +173,7 @@ impl DockerData {
|
|||||||
|
|
||||||
/// Get all current containers, handle into ContainerItem in the app_data struct rather than here
|
/// Get all current containers, handle into ContainerItem in the app_data struct rather than here
|
||||||
/// Just make sure that items sent are guaranteed to have an id
|
/// Just make sure that items sent are guaranteed to have an id
|
||||||
/// Will ignore any container that contains `oxker` as an entry point
|
/// Will ignore any container that uses `./start_oxker.sh` as an entry point, unless the `-s` flag is set
|
||||||
pub async fn update_all_containers(&mut self) -> Vec<(bool, ContainerId)> {
|
pub async fn update_all_containers(&mut self) -> Vec<(bool, ContainerId)> {
|
||||||
let containers = self
|
let containers = self
|
||||||
.docker
|
.docker
|
||||||
@@ -188,7 +188,11 @@ impl DockerData {
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|f| match f.id {
|
.filter_map(|f| match f.id {
|
||||||
Some(_) => {
|
Some(_) => {
|
||||||
if f.command.as_ref().map_or(false, |c| c.contains("oxker")) {
|
if f.command
|
||||||
|
.as_ref()
|
||||||
|
.map_or(false, |c| c.starts_with("./start_oxker.sh"))
|
||||||
|
&& self.args.show_self
|
||||||
|
{
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(f)
|
Some(f)
|
||||||
@@ -200,9 +204,6 @@ impl DockerData {
|
|||||||
|
|
||||||
self.app_data.lock().update_containers(&mut output);
|
self.app_data.lock().update_containers(&mut output);
|
||||||
|
|
||||||
let current_sort = self.app_data.lock().get_sorted();
|
|
||||||
self.app_data.lock().set_sorted(current_sort);
|
|
||||||
|
|
||||||
// Just get the containers that are currently running, or being restarted, no point updating info on paused or dead containers
|
// Just get the containers that are currently running, or being restarted, no point updating info on paused or dead containers
|
||||||
output
|
output
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@@ -263,7 +264,7 @@ impl DockerData {
|
|||||||
tokio::spawn(Self::update_log(
|
tokio::spawn(Self::update_log(
|
||||||
docker,
|
docker,
|
||||||
id.clone(),
|
id.clone(),
|
||||||
self.timestamps,
|
self.args.timestamp,
|
||||||
0,
|
0,
|
||||||
app_data,
|
app_data,
|
||||||
spawns,
|
spawns,
|
||||||
@@ -288,7 +289,7 @@ impl DockerData {
|
|||||||
tokio::spawn(Self::update_log(
|
tokio::spawn(Self::update_log(
|
||||||
docker,
|
docker,
|
||||||
container.id.clone(),
|
container.id.clone(),
|
||||||
self.timestamps,
|
self.args.timestamp,
|
||||||
container.last_updated,
|
container.last_updated,
|
||||||
app_data,
|
app_data,
|
||||||
spawns,
|
spawns,
|
||||||
@@ -323,6 +324,7 @@ impl DockerData {
|
|||||||
let loading_spin = self.loading_spin(loading_uuid).await;
|
let loading_spin = self.loading_spin(loading_uuid).await;
|
||||||
|
|
||||||
let all_ids = self.update_all_containers().await;
|
let all_ids = self.update_all_containers().await;
|
||||||
|
|
||||||
self.update_all_container_stats(&all_ids);
|
self.update_all_container_stats(&all_ids);
|
||||||
|
|
||||||
// Maybe only do a single one at first?
|
// Maybe only do a single one at first?
|
||||||
@@ -410,22 +412,22 @@ impl DockerData {
|
|||||||
|
|
||||||
/// Initialise self, and start the message receiving loop
|
/// Initialise self, and start the message receiving loop
|
||||||
pub async fn init(
|
pub async fn init(
|
||||||
args: CliArgs,
|
|
||||||
app_data: Arc<Mutex<AppData>>,
|
app_data: Arc<Mutex<AppData>>,
|
||||||
docker: Arc<Docker>,
|
docker: Arc<Docker>,
|
||||||
gui_state: Arc<Mutex<GuiState>>,
|
gui_state: Arc<Mutex<GuiState>>,
|
||||||
receiver: Receiver<DockerMessage>,
|
receiver: Receiver<DockerMessage>,
|
||||||
is_running: Arc<AtomicBool>,
|
is_running: Arc<AtomicBool>,
|
||||||
) {
|
) {
|
||||||
|
let args = app_data.lock().args;
|
||||||
if app_data.lock().get_error().is_none() {
|
if app_data.lock().get_error().is_none() {
|
||||||
let mut inner = Self {
|
let mut inner = Self {
|
||||||
app_data,
|
app_data,
|
||||||
|
args,
|
||||||
docker,
|
docker,
|
||||||
gui_state,
|
gui_state,
|
||||||
initialised: false,
|
initialised: false,
|
||||||
receiver,
|
receiver,
|
||||||
spawns: Arc::new(Mutex::new(HashMap::new())),
|
spawns: Arc::new(Mutex::new(HashMap::new())),
|
||||||
timestamps: args.timestamp,
|
|
||||||
is_running,
|
is_running,
|
||||||
binate: Binate::One,
|
binate: Binate::One,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ pub struct CliArgs {
|
|||||||
#[clap(short = 'r', conflicts_with = "color")]
|
#[clap(short = 'r', conflicts_with = "color")]
|
||||||
pub raw: bool,
|
pub raw: bool,
|
||||||
|
|
||||||
|
/// Show self when running as a docker container
|
||||||
|
#[clap(short = 's')]
|
||||||
|
pub show_self: bool,
|
||||||
|
|
||||||
/// Don't draw gui - for debugging - mostly pointless
|
/// Don't draw gui - for debugging - mostly pointless
|
||||||
#[clap(short = 'g')]
|
#[clap(short = 'g')]
|
||||||
pub gui: bool,
|
pub gui: bool,
|
||||||
@@ -43,6 +47,7 @@ impl CliArgs {
|
|||||||
color: args.color,
|
color: args.color,
|
||||||
docker_interval: args.docker_interval,
|
docker_interval: args.docker_interval,
|
||||||
gui: !args.gui,
|
gui: !args.gui,
|
||||||
|
show_self: !args.show_self,
|
||||||
raw: args.raw,
|
raw: args.raw,
|
||||||
timestamp: !args.timestamp,
|
timestamp: !args.timestamp,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user