Skip to content

Commit

Permalink
fix macOs cpu_count (#315)
Browse files Browse the repository at this point in the history
* fix macOs cpu_count
fix macOs  ps aux

* Update scripts-test.yml

* Update scripts-test.yml

* Update scripts-test.yml

* Update scripts-test.yml

---------

Co-authored-by: Xinwei Xiong <[email protected]>
  • Loading branch information
mrwenhui and cubxxw authored Dec 18, 2023
1 parent f11a043 commit 0140e82
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 12 deletions.
37 changes: 33 additions & 4 deletions .github/workflows/scripts-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,46 @@ on:

jobs:
execute-scripts:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up environment
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt-get update
# Add other Linux specific setup here
elif [ "$RUNNER_OS" == "macOS" ]; then
# Add macOS specific setup here
brew update
fi
shell: bash

# - name: Install latest Bash (macOS only)
# if: runner.os == 'macOS'
# run: |
# /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# brew update

# brew install bash
# brew install gnu-sed

# echo "/usr/local/bin" >> $GITHUB_PATH
# echo "$(brew --prefix)/opt/gnu-sed/libexec/gnubin" >> $GITHUB_PATH

# brew install --cask docker
# open /Applications/Docker.app

- name: Build Chat
run: |
sudo make build
sudo chmod +x ./scripts/build_all_service.sh
sudo ./scripts/build_all_service.sh
make build
chmod +x ./scripts/build_all_service.sh
./scripts/build_all_service.sh
shell: bash

- name: deploy all services
Expand Down
18 changes: 11 additions & 7 deletions scripts/build_all_service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,20 @@ logs_dir="$OPENIM_ROOT/logs"
echo "==> bin_dir=$bin_dir"
echo "==> logs_dir=$logs_dir"


cd $SCRIPTS_ROOT/..

# Get the current operating system and architecture
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)

# CPU core number
cpu_count=$(lscpu | grep -e '^CPU(s):' | awk '{print $2}')
echo -e "${GREEN_PREFIX}======> cpu_count=$cpu_count${COLOR_SUFFIX}"
if [[ "$OS" == "darwin" ]]; then
cpu_count=$(sysctl -n hw.ncpu)
elif [[ "$OS" == "linux" ]]; then
cpu_count=$(lscpu | grep -e 'CPU(s):' | awk '{print $3}')
else [[ "$OS" == "windows" ]];
cpu_count=$(lscpu | grep -e 'CPU(s):' | awk '{print $3}')
fi

# Count the number of concurrent compilations (half the number of cpus)
compile_count=$((cpu_count / 2))
Expand All @@ -63,10 +71,6 @@ if [ $? -ne 0 ]; then
exit 1
fi

# Get the current operating system and architecture
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)

# Select the repository home directory based on the operating system and architecture
if [[ "$OS" == "darwin" ]]; then
if [[ "$ARCH" == "x86_64" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion scripts/stop_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ for i in ${service_port_name[*]}; do
list=$(cat $OPENIM_ROOT/config/config.yaml | grep -w ${i} | awk -F '[:]' '{print $NF}')
list_to_string $list
for j in ${ports_array}; do
name="ps -aux |grep -w $j |grep -v grep"
name="ps aux |grep -w $j |grep -v grep"
count="${name}| wc -l"
if [ $(eval ${count}) -gt 0 ]; then
pid="${name}| awk '{print \$2}'"
Expand Down

0 comments on commit 0140e82

Please sign in to comment.