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) |
|
||||
|```-c```| attempt to color the logs (conflicts with -r) |
|
||||
|```-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 |
|
||||
|
||||
## Build step
|
||||
|
||||
@@ -55,5 +55,6 @@ FROM alpine:latest AS runtime
|
||||
COPY --from=builder /oxker /usr/local/bin
|
||||
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"]
|
||||
|
||||
@@ -8,7 +8,8 @@ FROM alpine:latest AS runtime
|
||||
COPY ./target/x86_64-unknown-linux-musl/release/oxker /usr/local/bin
|
||||
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"]
|
||||
|
||||
## One liner to build musl program, build docker image, then execute the image
|
||||
|
||||
+13
-11
@@ -51,14 +51,14 @@ impl Binate {
|
||||
|
||||
pub struct DockerData {
|
||||
app_data: Arc<Mutex<AppData>>,
|
||||
args: CliArgs,
|
||||
binate: Binate,
|
||||
docker: Arc<Docker>,
|
||||
gui_state: Arc<Mutex<GuiState>>,
|
||||
initialised: bool,
|
||||
is_running: Arc<AtomicBool>,
|
||||
receiver: Receiver<DockerMessage>,
|
||||
spawns: Arc<Mutex<HashMap<SpawnId, JoinHandle<()>>>>,
|
||||
timestamps: bool,
|
||||
binate: Binate,
|
||||
}
|
||||
|
||||
impl DockerData {
|
||||
@@ -173,7 +173,7 @@ impl DockerData {
|
||||
|
||||
/// 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
|
||||
/// 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)> {
|
||||
let containers = self
|
||||
.docker
|
||||
@@ -188,7 +188,11 @@ impl DockerData {
|
||||
.into_iter()
|
||||
.filter_map(|f| match f.id {
|
||||
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
|
||||
} else {
|
||||
Some(f)
|
||||
@@ -200,9 +204,6 @@ impl DockerData {
|
||||
|
||||
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
|
||||
output
|
||||
.into_iter()
|
||||
@@ -263,7 +264,7 @@ impl DockerData {
|
||||
tokio::spawn(Self::update_log(
|
||||
docker,
|
||||
id.clone(),
|
||||
self.timestamps,
|
||||
self.args.timestamp,
|
||||
0,
|
||||
app_data,
|
||||
spawns,
|
||||
@@ -288,7 +289,7 @@ impl DockerData {
|
||||
tokio::spawn(Self::update_log(
|
||||
docker,
|
||||
container.id.clone(),
|
||||
self.timestamps,
|
||||
self.args.timestamp,
|
||||
container.last_updated,
|
||||
app_data,
|
||||
spawns,
|
||||
@@ -323,6 +324,7 @@ impl DockerData {
|
||||
let loading_spin = self.loading_spin(loading_uuid).await;
|
||||
|
||||
let all_ids = self.update_all_containers().await;
|
||||
|
||||
self.update_all_container_stats(&all_ids);
|
||||
|
||||
// Maybe only do a single one at first?
|
||||
@@ -410,22 +412,22 @@ impl DockerData {
|
||||
|
||||
/// Initialise self, and start the message receiving loop
|
||||
pub async fn init(
|
||||
args: CliArgs,
|
||||
app_data: Arc<Mutex<AppData>>,
|
||||
docker: Arc<Docker>,
|
||||
gui_state: Arc<Mutex<GuiState>>,
|
||||
receiver: Receiver<DockerMessage>,
|
||||
is_running: Arc<AtomicBool>,
|
||||
) {
|
||||
let args = app_data.lock().args;
|
||||
if app_data.lock().get_error().is_none() {
|
||||
let mut inner = Self {
|
||||
app_data,
|
||||
args,
|
||||
docker,
|
||||
gui_state,
|
||||
initialised: false,
|
||||
receiver,
|
||||
spawns: Arc::new(Mutex::new(HashMap::new())),
|
||||
timestamps: args.timestamp,
|
||||
is_running,
|
||||
binate: Binate::One,
|
||||
};
|
||||
|
||||
@@ -23,6 +23,10 @@ pub struct CliArgs {
|
||||
#[clap(short = 'r', conflicts_with = "color")]
|
||||
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
|
||||
#[clap(short = 'g')]
|
||||
pub gui: bool,
|
||||
@@ -43,6 +47,7 @@ impl CliArgs {
|
||||
color: args.color,
|
||||
docker_interval: args.docker_interval,
|
||||
gui: !args.gui,
|
||||
show_self: !args.show_self,
|
||||
raw: args.raw,
|
||||
timestamp: !args.timestamp,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user