글쓴이 보관물: litcoder

Fitbit ultra

사실 계속 마음속에 뒀던건 Nike+ fuelband 였는데 ZD Net에 올라온 Prizefight: Nike+ Fuelband vs. FitBit Ultra을 보고 약간의 망설이던 차에 Best Buy에 갈 기회가 있었는데 어느새 내 손에는 fitbit ultra가 들려 있었다.

$99.99 가격표만 보고 마음먹었는데, 계산할 때 보니 $107 ‘아차 세금..’ 사고 싶은 파란색이 없어서 빨간색으로 사긴 했지만.. 만보계도 샀으니 열심히 걸어 다녀야지.

Repo mirroring

한국과 미국 처럼 거리상으로 멀리 떨어져 있는 경우, 한쪽에서 source를 sync하기 위해서는 시간이 너무 많이 걸린다. Mirror를 설정하고 주기적으로 source를 sync 해 오도록 하면 시간과 load를 줄일 수 있다. 다음은 Ubuntu 10.04 LTS 기준으로한 repo mirror server 설정방법에 대해 설명한다.

1. Git daemon 설정
: xinetd를 설치하고 git-daemon을 설정한다.

$> sudo apt-get install xinetd
$>sudo vi /etc/xinetd.d/git-daemon

service git
{
        disable = no
        type            = UNLISTED
        port            = 9418
        socket_type     = stream
        wait            = no
        user            = nobody
        server          = /usr/bin/git
        server_args     = daemon --inetd --export-all --base-path=/public/gitmirrors/
        log_on_failure  += USERID
}
$> sudo /etc/init.d/xinetd restart
혹은
$> sudo service xinetd restart

 

2. Mirror repository 만들기
: 외부에서 접근할 공간을 생성하고 mirror를 만든다.

$>sudo mkdir -p /public/gitmirrors/
$>chmod 777 /public/gitmirrors/
$>mkdir /public/gitmirrors/PROJECT_TOP_DIR
$>cd  /public/gitmirrors/PROJECT_TOP_DIR
$>repo init -u ssh://USER_ID@SERVER_ADDRESS_AND_PORT/platform/manifest.git -b <BRANCH_NAME> --mirror
$>repo sync

 

3. Fetching address 변경
: manifest.git을 변경시켜서 새로운 branch로 server에 push 한다.

먼저 manifest.git을 cloning 해오자

$> mkdir ~/temp/manifest
$> cd ~/temp/manifest
$> git clone /public/gitmirrors/PROJECT_TOP_DIR/platform/manifest.git

default.xml의 fetch address를 변경해서 mirror에서 받아오도록 수정한다.

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
  <remote name=REMOTE_NAME fetch="git://MIRROR_SERVER_ADDR/PROJECT_TOP_DIR" review=REVIEW_SITE_ADDR />

...

수정된 default.xml을 새로운 branch에 push 한다.

$>git checkout -b  MIRROR_BRANCH_NAME
$>git add .
$>git commit -m "Updated fetch URL to mirror"
$>git push origin MIRROR_BRANCH_NAME

 

4. Client에서 mirror로 부터 source sync 하기

repo init할때 mirror branch를 명시한다.

$> repo init -u git://MIRROR_SERVER_ADDR/PROJECT_TOP_DIR/platform/manifest.git -b MIRROR_BRANCH_NAME
$> repo sync

 

5. 주기적인 sync를 위한 crontab과 sync script 작성

$> crontab -e
# m h  dom mon dow   command

# 매시 00분 마다 repo sync를 수행
0 * * * * ~/bin/cron_repo_sync.sh

repo sync script
: 호출될 때마다 mirror directory에 있는 내용들을 본국에서 송환해 온다.

#!/bin/bash
# cron repo sync script.
# Syncs all mirrors under the PUBLIC_REPO_DIRS_ROOT. - skywriter

PUBLIC_REPO_DIRS_ROOT="/public/gitmirrors/"
REPO_PATH="/usr/local/bin/repo"

sync_cmd="$REPO_PATH sync -j20"
repodirs=`ls ${PUBLIC_REPO_DIRS_ROOT}`

echo "start syncing"
for repodir in $repodirs
do
  echo "syncing [$repodir] at `date`"
  cd ${PUBLIC_REPO_DIRS_ROOT}$repodir/
  $sync_cmd 2>&1
done
echo "done at `date`"