Skip to content

Commit 53610e1

Browse files
author
Amir
committed
Adds random with bc to use smaller fraction
1 parent 5e5d10a commit 53610e1

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
FROM alpine:3.8
2+
RUN apk add --no-cache bc
23
COPY ./entrypoint.sh /
34
ENTRYPOINT ["/entrypoint.sh"]
5+
CMD [ "100", "5000" ]

entrypoint.sh

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
#!/bin/sh
22
while [ 1 ]
33
do
4-
waitTime=$(shuf -i 1-5 -n 1)
5-
sleep $waitTime &
6-
wait $!
7-
instruction=$(shuf -i 0-4 -n 1)
8-
d=`date -Iseconds`
9-
case "$instruction" in
10-
"1") echo "$d ERROR something happened in this execution."
4+
WAIT=$(shuf -i $1-$2 -n 1)
5+
sleep $(echo "scale=4; $WAIT/1000" | bc)
6+
I=$(shuf -i 1-4 -n 1)
7+
D=`date -Iseconds`
8+
case "$I" in
9+
"1") echo "$D ERROR An error is usually an exception that has been caught and not handled."
1110
;;
12-
"2") echo "$d INFO takes the value and converts it to string."
11+
"2") echo "$D INFO This is less important than debug log and is often used to provide context in the current task."
1312
;;
14-
"3") echo "$d WARN variable not in use."
13+
"3") echo "$D WARN A warning that should be ignored is usually at this level and should be actionable."
1514
;;
16-
"4") echo "$d DEBUG first loop completed."
15+
"4") echo "$D DEBUG This is a debug log that shows a log that can be ignored."
1716
;;
1817
esac
1918
done

0 commit comments

Comments
 (0)