ラベル git の投稿を表示しています。 すべての投稿を表示
ラベル git の投稿を表示しています。 すべての投稿を表示

2012年10月1日月曜日

そろそろ通信回線について言っておくか



iPhone5の到来によりコスト配分が変わったので、
通信回線について言っておきます。

通信回線
以下、最近使っていた通信回線ですが、iPhone5が加わったのでこれを整理したいと思います。




































通信回線電波状況通信速度コストコメント
docomo 3Gバランスが良い。
いろんな場所で使える安心のドコモ。
IIJmio×月額945円でdocomo回線なのが最大の魅力。
通信速度が128kbpsなのでメールとtwitterだけなど
使うものを限定するかWifiと併用すればコスト面で最強。
オプションでLTEも使える。
WiMAXテザリングで通信データ量の上限がないのはこれだけ。
PCを使う場合はとくに制限がないのは安心です。
建物に囲まれた場所や地下などで
使えないことが多い。
au LTE◎(3Gも含む)iPhone5を購入しなければ使うことはないと思いますが、
LTEでテザリングできるのは魅力です。
まだLTEが普及していないので来年以降に期待。


docomo 3G


とにかくバランスがいいけど、これと言う売りがないのがドコモです。
あえて言うなら地方へ行った時の安心感ですね。
LTE(Xi)への移行はコスト面でデメリットが大きいので、もう少しがんばってほしい。
今後は、できるだけ安く運用できるようにプランやオプションの見直しを行い、
電話、メールなどはすべてiPhone5に転送するように設定。
塩漬け状態ですね。

IIJmio


私の場合は、ウェルカムパック for イオンを購入しました。
通信速度が128kbspなので用途が限られます。
追加料金でLTEも使えるのですが、コストを下げるがの目的であれば使わないと思います。
自宅、職場、駅、カフェなどでWifiが使えればこれでも十分ですね。
テザリングはWifiルータによっては使えるらしいですが、
128kなのであまり期待しないほうがよいかと思います。
Wifiと併用してAndroid開発端末用かな。

WiMAX


通信制限なくテザリングできるのはこれだけですね。
コスト面でもLTEと比べると安いので1年くらいお世話になりました。
ビルで囲まれた場所や地下で使えなかったことが残念です。
今後はLTEに設備投資していくと思われるので、どう差別化していくのかが心配です。
iPhone5を購入したため手放すことにしましたが、今後は容量を気にする必要があるのでそれが気がかりです。

au LTE


auに限らずLTEの料金は高いですね。これはどのキャリアでも言えるのですが、
LTEで通信できる場所はまだ限られているので割高感は否めません。
良くも悪くもiPhone5のおかげでLTEの競争が激しくなるので、
来年はLTEがどこでも使えるようになって安くなることを祈ります。
二年縛りですが、メインのdocomoは塩漬けで残しているので、
より良いサービスがあればすぐに解約します。

iOS6の地図で騒がれているAppleですが、LTEだけ見てもiPhoneの影響は大きいですね。
NFCもつけてほしかったな・・・。

最後にこれが言いたかった。
docomoさん、応援してます!
ユーザーの声をもっと聞いてほしいな。

2012年8月27日月曜日

残暑お見舞い申し上げます

残暑お見舞い申し上げます。

少しずつ秋が近づいているような気がすると思えば、
連日の猛暑でそんなことも吹き飛んでいますね。
たぶん毎年思うのですが、残暑って年々厳しくなっているような気がします。

もうすぐ9月ですが、iPhoneやらKindleやらいろいろあるのと、
個人的にも忙しくなりそうな予感ですので、体には気をつけたいものです。

最近、何をしているかよく聞かれるのですが、
先月までドラゴンズドグマで今月からドラクエ10・・・ではなくて・・・、
やっと近々お話ができるところまできましたので、
来月あたりご挨拶に伺おうと思っております。

仕事面では、これまではサーバサイドの開発を極めようと精進してきましたが、
直近は主にクライアントサイドの技術を勉強しています。
クライアントサイドの技術と言っても広範囲に及ぶのですが、
まずは本業のプログラミングからで、地味にJavaScript、Obejctive-Cの勉強などをしています。
また、サーバサイドですが、Rubyも始めました。
今後も少しでも誰かの手助けになれるような技術を身につけようと思います。

業界によっては夏期に夏期休暇を取れない方もいらっしゃると思いますが、
夏の疲れには、充分にご注意ください。

今後ともよろしくお願い申し上げます。

2012年6月28日木曜日

「git-flowによるブランチ管理」を試してみる

git を使いこなすのが難しいと感じる今日このごろ。
皆様いかがお過ごしでしょうか。
gitを使っていると作業中のブランチどうするのとかいろいろ気になりますね。
でも、ブランチの管理って複雑なんだよなーとか・・・思っていたらオライリーのサイトで「git-flowによるブランチ管理」という目からうろこのような記事がありました。
ブランチ管理が共通化できて便利そうなので試してみること・・・。

ちなみにgit-daliyというGREEのインフラの方(sotarokさん)が作成したものもあるようです。
こちらは、PHPで作られているようですね。

参考

git-flow によるブランチの管理
A successful Git branching model(日本語訳)
gitflow

コマンドが出力するメッセージも合わせて記述しているので、多少見にくいかもしれません。
内容的にあまり変わりないと思うので、試したい場合は、上記参考サイトの「git-flowによるブランチ管理」をおすすめいたします。

試した環境

CentOS 6.2
Git version 1.7.11.1 (2012/6/28現在のリリースバージョン)

1. git-flowをインストールする

いきなり少し違いますが、この環境では、gitを/usr/local/gitにインストールしたので、コマンドにINSTALL_PREFIXオプションつけています。
sudo su -
cd /usr/local/src
wget --no-check-certificate -q -O - https://github.com/nvie/gitflow/raw/develop/contrib/gitflow-installer.sh | env INSTALL_PREFIX=/usr/local/git/bin bash
chmod -R 755 /usr/local/git/bin

2. 空のリポジトリを作成する

git init --bare --shared=group foobar.git
cp foobar.git/hooks/post-update.sample foobar.git/hooks/post-update

3. 作業用のディレクトリに移動して空のリポジトリをcloneする

git clone /var/git/foobar.git

4. git-flowを導入する

cd foobar
git flow init
デフォルトのままEnterキーを押し続けます。
次の内容を聞かれますので必要があれば適宜で変更してください。
No branches exist yet. Base branches must be created now.
Branch name for production releases: [master]
Branch name for "next release" development: [develop]
How to name your supporting branch prefixes?
Feature branches? [feature/]
Release branches? [release/]
Hotfix branches? [hotfix/]
Support branches? [support/]
Version tag prefix? []
これなら既存のプロジェクトにも導入できますね。

5. 機能(helloworld)を追加する

git flow feature start helloworld
Switched to a new branch 'feature/helloworld'
Summary of actions:
- A new branch 'feature/helloworld' was created, based on 'develop'
- You are now on branch 'feature/helloworld'

Now, start committing on your feature. When done, use:

git flow feature finish helloworld

6. ブランチを確認する

git branch
develop
* feature/helloworld
master

7. 機能を追加する

vi helloworld.pl
#!/usr/bin/perl

use strict;
use warnings;

print "Hello World\n";

8. リポジトリに追加する

git add helloworld.pl
git commit -m "HelloWorld"

[feature/helloworld 0fabb48] HelloWorld
 1 file changed, 7 insertions(+)
 create mode 100755 helloworld.pl
コミットしました。

9. 開発用ブランチ(develop)にマージする

git flow feature finish helloworld

Switched to branch 'develop'
Updating e69c50f..0fabb48
Fast-forward
 helloworld.pl | 7 +++++++
 1 file changed, 7 insertions(+)
 create mode 100755 helloworld.pl
 Deleted branch feature/helloworld (was 0fabb48).
 
 Summary of actions:
 - The feature branch 'feature/helloworld' was merged into 'develop'
 - Feature branch 'feature/helloworld' has been removed
 - You are now on branch 'develop'
上記のメッセージのとおり、
・feature/helloworldブランチがdevelopブランチにマージします。
・feature/helloworldブランチは削除されます。
・developブランチに切り替わります。

10. ブランチを確認する

git branch
* develop
  master
確かにそのとおりです。

11. developブランチをpushする

git push origin develop

Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 438 bytes, done.
Total 5 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (5/5), done.
To /var/git/foobar.git
 * [new branch]      develop -> develop

12. ver1.0.0としてリリースブランチを作成する

git flow release start 1.0.0

Switched to a new branch 'release/1.0.0'
Summary of actions:
- A new branch 'release/1.0.0' was created, based on 'develop'
- You are now on branch 'release/1.0.0'

Follow-up actions:- Bump the version number now!
- Start committing last-minute fixes in preparing your release
- When done, run:

  git flow release finish '1.0.0'

13. ブランチを確認

git branch
  develop
  master
  * release/1.0.0

14. READMEを作成する

vi README
README
====================================

- 1.0.0: print "Hello World"

14. リリースする

git add README
git commit -m 'update readme for release 1.0.0'

[release/1.0.0 e331ab0] update readme for release 1.0.0
 1 file changed, 4 insertions(+)
 create mode 100644 README
 
 git flow release finish 1.0.0
 
 # エディタが開きマージの内容やtagの入力など求められるので入力して保存する
 
 Switched to branch 'master'
 Merge made by the 'recursive' strategy.
 README        | 4 ++++
 helloworld.pl | 7 +++++++<
 2 files changed, 11 insertions(+)
 create mode 100644 README
 create mode 100755 helloworld.pl
 Switched to branch 'develop'
 Merge made by the 'recursive' strategy.
 README | 4 ++++
 1 file changed, 4 insertions(+)
 create mode 100644 README
 Deleted branch release/1.0.0 (was e331ab0).
 
 Summary of actions:
 - Latest objects have been fetched from 'origin'
 - Release branch has been merged into 'master'
 - The release was tagged '1.0.0'
 - Release branch has been back-merged into 'develop'
 - Release branch 'release/1.0.0' has been deleted

15. ブランチを確認する

git branch
* develop
master

16. タグを確認する

git tag
1.0.0

17. pushする

git push

Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 442 bytes, done.
Total 4 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
To /var/git/foobar.git
  0fabb48..e006137  develop -> develop

18. タグをpushする

git push origin 1.0.0

Counting objects: 2, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 342 bytes, done.
Total 2 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (2/2), done.
To /var/git/foobar.git
* [new tag]         1.0.0 -> 1.0.0

19. 修正用のブランチを作成する

git flow hotfix start 1.0.1-bugfix

Switched to a new branch 'hotfix/1.0.1-bugfix'

Summary of actions:
- A new branch 'hotfix/1.0.1-bugfix' was created, based on 'master'
- You are now on branch 'hotfix/1.0.1-bugfix'

Follow-up actions:
- Bump the version number now!
- Start committing your hot fixes
- When done, run:

  git flow hotfix finish '1.0.1-bugfix'

20. ファイルを修正する

次のようにhelloworld.plに1行追加しました。
git diff
diff --git a/helloworld.pl b/helloworld.pl
index 2382e77..6fa1737 100755
--- a/helloworld.pl
+++ b/helloworld.pl
@@ -4,4 +4,5 @@ use strict;
 use warnings;
 
 print "Hello World\n";
 +print "BugFix\n";

21. 修正版をコミットする

git commit helloworld.pl -m "Bugfix."

[hotfix/1.0.1-bugfix be609ab] Bugfix.
 1 file changed, 1 insertion(+)

22. 修正版を適用する

git flow hotfix finish 1.0.1-bugfix

# マージする内容の確認やタグの入力など求められるので入力して保存する

Switched to branch 'master'
Merge made by the 'recursive' strategy.
 helloworld.pl | 1 +
 1 file changed, 1 insertion(+)
Switched to branch 'develop'
Merge made by the 'recursive' strategy.
 helloworld.pl | 1 +
 1 file changed, 1 insertion(+)
Deleted branch hotfix/1.0.1-bugfix (was be609ab).

Summary of actions:
- Latest objects have been fetched from 'origin'
- Hotfix branch has been merged into 'master'
- The hotfix was tagged '1.0.1-bugfix'
- Hotfix branch has been back-merged into 'develop'
- Hotfix branch 'hotfix/1.0.1-bugfix' has been deleted

23. タグの確認

git tag
1.0.0
1.0.1-bugfix

24. pushする

git push

Counting objects: 6, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 501 bytes, done.
Total 4 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
To /var/git/foobar.git
   e006137..da2ab95  develop -> develop

git push origin 1.0.1-bugfix

Counting objects: 2, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 355 bytes, done.
Total 2 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (2/2), done.
To /var/git/foobar.git
 * [new tag]         1.0.1-bugfix -> 1.0.1-bugfix
git flowすばらしいです。
私のようなブランチ管理が苦手な人でも使えそうです。

1点気になったのは、リリースのバージョン情報ですね。
細かい修正が多い場合は数値がどんどん追加されてカオスになりそうですね。
そのあたりの運用ポリシーをどうするかが問題になりそうです。

2012年6月19日火曜日

nginxでgitリポジトリの公開 - Smart HTTPを試してみた



nginxでgitリポジトリを公開してみます。
Smart HTTPというのが使えるようですが、こちらの例ではApache HTTP Serverでしたが、
特別なことは必要なさそうなので、nginxで試してみます。
80番ポートで通信できるとか、認証方法によっては鍵が必要なかったりといろいろ使い道がありそうですね。


こちらを参考にしました。



nginx 1.2.1を使用しますが、インストール手順は省略します。
上記の記事によるとgit-http-backendを動かす必要があるので、fcgiwrapを使ってみます。

fcgiwrapインストール




  • fcgiwrapインストール

yum -y install fcgi-devel.x86_64
cd /usr/loca/src
git clone git://github.com/gnosek/fcgiwrap.git
cd fcgiwrap
autoreconf -i
./configure --prefix=/usr/local/fcgiwrap
make
make install



  • fcgiwrapの起動

sudo -u www /usr/local/fcgiwrap/sbin/fcgiwrap -c2 -s unix:/tmp/fcgiwrap.sock >> /var/log/fcgiwrap.log &



nginx設定




  • 試しに設定したserverセクションです。

ドメイン名、パス、認証方法などは適宜変更してください。

server {
listen   80;
server_name git.example.com;

access_log /usr/local/nginx/logs/git/access_log;
error_log /usr/local/nginx/logs/git/error_log;

location / {
auth_basic            "Restricted";
auth_basic_user_file  htpasswd;

include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/local/git/libexec/git-core/git-http-backend;
fastcgi_param GIT_PROJECT_ROOT /var/git;
fastcgi_param GIT_HTTP_EXPORT_ALL "";
fastcgi_param PATH_INFO $uri;

fastcgi_pass unix:/tmp/fcgiwrap.sock;
}
}


設定が完了したらnginxを再起動します。
認証が無いと誰でもアクセスできるので、なんらかの認証は設定した方がいいですね。



gitリポジトリ作成




  • 空のリポジトリ作成と初期設定

git init --bare --shared=group foobar.git
cd foobar.git
cp hooks/post-update.sample hooks/post-update
git update-server-info
git config http.receivepack true



  • パーミッションの設定

環境の合わせて適宜gitリポジトリのディレクトリに設定してください。

動作確認



git clone http://git.example.com/foobar.git
Cloning into 'foobar'...
Username:
Password:
warning: You appear to have cloned an empty repository.

cd foobar
touch test.txt
git add .

git commit -m 'test'
[master (root-commit) b578ac5] test
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 test.txt
git push origin master

git push origin master
Username:
Password:
Counting objects: 3, done.
Writing objects: 100% (3/3), 206 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To http://git.example/com/foobar.git
* [new branch]      master -> master



pushができない(receivepackが有効でない場合のエラー)


receive-packの設定が無効の場合は、pushができませんでした。
アクセスログに401やWebDAVのPROPFINDメソッドとか出てたりしたので若干混乱します。
原因は、下記のようにfcgiwrapが出力するreceive-packの設定でした。

gitコマンドのエラー
error: Cannot access URL http://git.example.com/foobar.git/, return code 22
fatal: git-http-push failed

fcgiwrapのエラー
Service not enabled: 'receive-pack'


これらの必要な設定(http.receivepack)は、git-http-backend(1) Manual Pageに書いてありますね。

httpでも一通りgitが使えることが確認できました。