-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prepare profiler container to run both binaries
- Loading branch information
Showing
2 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |