Skip to content

Commit

Permalink
prepare profiler container to run both binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
cha87de committed Oct 27, 2018
1 parent e126b9a commit 520d479
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
20 changes: 18 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
FROM alpine:latest
RUN apk update
RUN apk add libvirt-client ncurses5-libs
RUN apk add libvirt-client ncurses5-libs git gettext curl bash make
RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
RUN ln -s /usr/lib/libncurses.so.5 /usr/lib/libtinfo.so.5

# use bpkg to handle complex bash entrypoints
RUN curl -Lo- "https://raw.githubusercontent.com/bpkg/bpkg/master/setup.sh" | bash
RUN bpkg install cha87de/bashutil -g

# copy entrypoint
RUN mkdir -p /opt/docker-init
ADD init /opt/docker-init

# add kvmtop binaries
ADD kvmtop /bin/kvmtop
ADD kvmprofiler /bin/kvmprofiler
CMD [ "/bin/kvmtop" ]

# set parameters
ENV PARAMS "-c qemu:///system --printer=text --cpu --mem --net --disk"

# start from init folder
WORKDIR /opt/docker-init
ENTRYPOINT ["./entrypoint"]
44 changes: 44 additions & 0 deletions init/entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# include bpkg dependencies
source /usr/local/bin/retry
source /usr/local/bin/bgo
source /usr/local/bin/bgowait

##############################################################################
function start_metrics(){
kvmtop $PARAMS
}
function start_profiler(){
kvmprofiler $PARAMS
}
function start(){
echo "starting applications..."
bgo start_metrics start_profiler
if [[ $? != 0 ]]; then
echo "start failed. exiting now." >&2
exit 1
fi
}

##############################################################################
function main(){
# start
start
if [[ $? != 0 ]]; then
echo "start failed. exiting now." >&2
exit 1
fi

# wait
echo "done. now waiting for services."
#freq=5; waitForN=-1; killTasks=0 # fail one, ignore (development mode)
freq=5; waitForN=1; killTasks=1 #fail one, fail all (production mode)
bgowait $freq $waitForN $killTasks
}

if [[ "$1" == "" ]]; then
main
else
exec "$@"
fi

0 comments on commit 520d479

Please sign in to comment.