Skip to content

Commit b946ec6

Browse files
authored
Merge pull request #45 from moevm/bind_process_to_cpu
Bind process to cpu
2 parents b3957d5 + 33cbb2c commit b946ec6

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

docker-compose.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
version: '3.8'
22

33
services:
4-
hash:
4+
worker:
55
build:
66
context: .
77
dockerfile: Dockerfile.hash
8-
container_name: worker
98
volumes:
109
- ./worker/data:/data
1110
working_dir: /data

scripts/start.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
set -e
3+
4+
CPU_COUNT=$(nproc)
5+
6+
docker-compose up -d --scale worker=$CPU_COUNT
7+
8+
for (( i=0; i<$CPU_COUNT; i++ ))
9+
do
10+
container_id=$(docker-compose ps -a -q worker | sed -n "$((i+1))p")
11+
if [ -n "$container_id" ]; then
12+
docker update --cpuset-cpus="$i" "$container_id"
13+
fi
14+
done
15+

0 commit comments

Comments
 (0)