-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcount.Vagrantfile
More file actions
79 lines (71 loc) · 2.78 KB
/
count.Vagrantfile
File metadata and controls
79 lines (71 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
Vagrant.configure("2") do |config|
nodes = {
"redis_pub_sub" => {},
"counter" => {},
"producer" => {}
}
nodes.each do |name, env_vars|
config.vm.define name do |node|
node.vm.box = "generic/ubuntu2004"
ip_suffix = case name
when "producer" then 10
when "redis_pub_sub" then 9
else 11 + name[1..-1].to_i
end
node.vm.network "private_network", ip: "192.168.56.#{ip_suffix}"
node.vm.synced_folder ".", "/app"
node.vm.provision "shell", inline: <<-SHELL
apt-get update -qq && apt-get install -y docker.io linuxptp
if [ "#{name}" = "redis_pub_sub" ]; then
docker run -d --name redis --network host redis:8.2.4-alpine \
redis-server --maxmemory 256mb --maxmemory-policy allkeys-lru --save ""
exit 0
fi
# Every node gets own state store (default config is fine)
docker rm -f redis || true
docker run -d --name redis --network host redis:8.2.4-alpine
# Every node gets its own placement
docker rm -f placement || true
docker run -d --name placement --network host daprio/placement:1.16.0 ./placement --port 50006
# Sidecar
docker rm -f #{name}-sidecar || true
docker run -d \
--name #{name}-sidecar \
--network host \
-v /app/config/redis/components-vagrant:/components \
daprio/daprd:edge \
./daprd \
--app-id #{name}-sidecar \
--app-port 3000 \
--resources-path /components \
--placement-host-address localhost:50006 \
--metrics-port 9091
sleep 2
# Application
docker rm -f #{name} || true
if [ "#{name}" = "producer" ]; then
docker run -d \
--name #{name} \
--network host \
-e ROLE=producer \
-e DAPR_HTTP_ENDPOINT=http://localhost:3500 \
-e METRICS_DIRECTORY=/app/metrics \
-e DAPR_GRPC_ENDPOINT=http://localhost:50001 \
-v /app/count/run/metrics_#{name}:/app/metrics \
collaborativestatemachines/cirrina-baselines-count:unstable
else
docker run -d \
--name #{name} \
--network host \
-e ROLE=counter \
-e DAPR_HTTP_ENDPOINT=http://localhost:3500 \
-e METRICS_DIRECTORY=/app/metrics \
-e DAPR_GRPC_ENDPOINT=http://localhost:50001 \
-v /app/count/run/metrics_#{name}:/app/metrics \
collaborativestatemachines/cirrina-baselines-count:unstable
fi
nohup bash -c 'while true; do docker stats --no-stream --format "$(date +%s),{{.Name}},{{.CPUPerc}},{{.MemUsage}}" >> /app/count/run/metrics_#{name}/docker_stats.csv; sleep 1; done' &
SHELL
end
end
end