{"id":1353,"date":"2014-01-19T17:57:31","date_gmt":"2014-01-19T08:57:31","guid":{"rendered":"http:\/\/kazu.tv\/blog\/?p=1353"},"modified":"2014-01-19T18:01:03","modified_gmt":"2014-01-19T09:01:03","slug":"automated-deployment-of-play-framework-project-using-fabric","status":"publish","type":"post","link":"https:\/\/kazu.tv\/blog\/2014\/01\/19\/automated-deployment-of-play-framework-project-using-fabric\/","title":{"rendered":"Fabric\u3067Play! framework\u30a2\u30d7\u30ea\u306e\u30c7\u30d7\u30ed\u30a4\u3092\u81ea\u52d5\u5316\u3057\u3066\u307f\u305f"},"content":{"rendered":"<p>\u968f\u5206\u524d\u304b\u3089\u3001\u52c9\u5f37\u304c\u3066\u3089\u500b\u4eba\u3067\u3061\u3087\u3053\u3061\u3087\u3053web\u30b5\u30a4\u30c8\u4f5c\u3063\u3066\u308b\u3002\u30c7\u30d7\u30ed\u30a4\u306fjar\u30d5\u30a1\u30a4\u30eb\u306e\u30b3\u30d4\u30fc\u3060\u3051\u3068\u306f\u8a00\u3048\u3001\u6bce\u56de\u624b\u52d5\u3067deploy\u3068\u30b5\u30fc\u30d3\u30b9\u518d\u8d77\u52d5\u3092\u3059\u308b\u306e\u306f\u3055\u3059\u304c\u306b\u9762\u5012\u306b\u306a\u3063\u3066\u304d\u305f\u306e\u3067\u3001\u30c7\u30d7\u30ed\u30a4\u3092\u81ea\u52d5\u5316\u3059\u308b\u30c4\u30fc\u30eb\u3092\u5c0e\u5165\u3059\u308b\u4e8b\u306b\u3057\u305f\u3002<\/p>\n<h2>\u74b0\u5883\u7b49<\/h2>\n<ul>\n<li>Play! framework 2.2<\/li>\n<li>web(app)\u3001DB\u3001\u30d0\u30c3\u30c1\u3067\u30b5\u30fc\u30d0\u30fc\u304c\u5206\u304b\u308c\u3066\u3044\u308b<\/li>\n<li>\u30c7\u30d7\u30ed\u30a4\u5148\u306f\u3044\u305a\u308c\u3082Linux<\/li>\n<li>\u30ed\u30fc\u30ab\u30eb\u958b\u767a\u74b0\u5883\u306fOS X Mavericks (10.9)<\/li>\n<li>Fabric 1.8.1\u3092\u4f7f\u7528<\/li>\n<\/ul>\n<p><!--more--><\/p>\n<h2>\u6700\u521dCapistrano\u306b\u3057\u3088\u3046\u3068\u3057\u305f\u304c\u3084\u3081\u305f<\/h2>\n<p>\u4ed5\u4e8b\u5148\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u4f7f\u3063\u3066\u3044\u308bCapistrano\u3092\u6700\u521d\u4f7f\u304a\u3046\u3068\u3057\u305f\u3002\u3067\u3082\u3001Capistrano\u306f\u5c11\u3057\u8a66\u3057\u305f\u3082\u306e\u306e\u4ee5\u4e0b\u306e\u7406\u7531\u3067\u6b62\u3081\u305f\u3002(Ruby on Rails\u306e\u5834\u5408\u306fCapistrano\u304c\u4e00\u756a\u826f\u3044\u9078\u629e\u80a2\u3060\u3068\u306f\u601d\u3046\u3051\u3069\u3002)<\/p>\n<ul>\n<li>\u6700\u65b0\u30d0\u30fc\u30b8\u30e7\u30f3\u306eCapistrano 3\u306f\u3001\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u304c\u975e\u5e38\u306b\u5c11\u306a\u3044\u3002<\/li>\n<li>\u30b5\u30fc\u30d0\u30fc\u4e0a\u3067git clone\u3092\u5b9f\u884c\u3057\u3066\u305d\u308c\u3092deploy\u3059\u308b\u3001\u3068\u3044\u3046\u306e\u304c\u60f3\u5b9a\u3055\u308c\u3066\u3044\u308b\u4f7f\u3044\u65b9\u306a\u306e\u3067\u3001\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u3067\u30d3\u30eb\u30c9\u3057\u3066jar\u3092deploy\u3059\u308b\u3068\u3044\u3046\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u3060\u3068\u3001\u4f7f\u3044\u306b\u304f\u3044\uff08\u3068\u3044\u3046\u304b\u4f7f\u308f\u306a\u3044\u6a5f\u80fd\u304c\u591a\u3044\uff09\u3002<\/li>\n<li><a title=\"\u5165\u9580 Capistrano 3 ~ \u5168\u3066\u306e\u624b\u4f5c\u696d\u3092\u751f\u307e\u308c\u308b\u524d\u306b\u6d88\u3057\u53bb\u308a\u305f\u3044\" href=\"http:\/\/labs.gree.jp\/blog\/2013\/12\/10084\/\" target=\"_blank\">\u3053\u3061\u3089\u306e\u30da\u30fc\u30b8<\/a>\u3067\u7d39\u4ecb\u3055\u308c\u3066\u3044\u308b\u3088\u3046\u306b\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30bf\u30b9\u30af\u3092\u524a\u9664\u3057\u3066\u3001\u30b7\u30f3\u30d7\u30eb\u306a\u30bf\u30b9\u30af\u3092\u5b9a\u7fa9\u3057\u3066\u4f7f\u3046\u3068\u3044\u3046\u3084\u308a\u65b9\u3082\u3042\u308a\u3060\u304c\u3001\u300c\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30bf\u30b9\u30af\u3092\u524a\u9664\u300d\u3068\u3044\u3046\u306e\u304c\u7121\u99c4\u306a\u6c17\u304c\u3059\u308b\u3002<\/li>\n<\/ul>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u3061\u3087\u3063\u3068\u30b0\u30b0\u3063\u305f\u7d50\u679c\u3001Python\u88fd\u306e<a title=\"Fabric\" href=\"http:\/\/docs.fabfile.org\/en\/1.8\/\" target=\"_blank\">Fabric<\/a>\u3068\u3044\u3046\u30c4\u30fc\u30eb\u306fCapistrano\u3088\u308a\u8584\u3044\u30b7\u30f3\u30d7\u30eb\u3089\u3057\u3044\u306e\u3067\u3001\u305d\u3063\u3061\u3092\u4f7f\u3063\u3066\u307f\u308b\u4e8b\u306b\u3057\u305f\u3002<\/p>\n<h2>\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u306bFabric\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n<p>OS X Mavericks\u306e\u5834\u5408\u3001\u6700\u521d\u304b\u3089python 2.7.5\u304c\u5165\u3063\u3066\u3044\u308b\u3088\u3046\u306a\u306e\u3067\u3001\u3053\u3063\u3061\u3092\u4f7f\u3046\u4e8b\u306b\u3057\u305f\u3002Homebrew\u3067\u74b0\u5883\u4f5c\u308b\u3068\u3001\u6700\u521d\u304b\u3089\u5165\u3063\u3066\u308bpython\u3068\u3054\u3061\u3083\u6df7\u305c\u306b\u306a\u308a\u305d\u3046\u306a\u306e\u3067\u3084\u3081\u305f\u3002\u3061\u306a\u307f\u306b\u3001\u81ea\u5206\u306epython\u306e\u77e5\u8b58\u306f\u6226\u95d8\u529b5\u7a0b\u5ea6\u306a\u306e\u3067\u3001\u4ee5\u4e0b\u306f\u53c2\u8003\u7a0b\u5ea6\u306b\u3002<\/p>\n<h3>pip, setuptools\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n<p>python\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u7ba1\u7406\u30c4\u30fc\u30eb\u3067\u3042\u308bpip\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3002\u8aad\u307f\u65b9\u306f\u300c\u3074\u3063\u3077\u300d\u3089\u3057\u3044\u304c\u3001\u3069\u3046\u3057\u3066\u3082<a title=\"\u30d4\u30c3\u30d4\" href=\"http:\/\/wiki.\u30dd\u30b1\u30e2\u30f3.com\/wiki\/%E3%83%94%E3%83%83%E3%83%94\" target=\"_blank\">\u30ab\u30ef\u30a4\u30a4\u7cfb\u306e\u30dd\u30b1\u30e2\u30f3<\/a>\u3092\u601d\u3044\u51fa\u3057\u3066\u3057\u307e\u3046\u3002<\/p>\n<pre class=\"brush: bash\">$ sudo easy_install pip<\/pre>\n<p>setuptools\u3068\u3044\u3046\u306e\u3082\u5fc5\u8981\u3089\u3057\u3044\u306e\u3067\u3001\u3053\u3061\u3089\u3082<a title=\"setuptools Installation Instructions\" href=\"https:\/\/pypi.python.org\/pypi\/setuptools#installation-instructions\" target=\"_blank\">\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a>\u306b\u5f93\u3063\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3002<\/p>\n<pre class=\"brush: bash\">$ wget https:\/\/bitbucket.org\/pypa\/setuptools\/raw\/bootstrap\/ez_setup.py -O - | sudo python<\/pre>\n<h3>Fabric\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n<p>\u5f8c\u306f\u3001pip\u3092\u4f7f\u3063\u3066Fabric\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/p>\n<pre class=\"brush: bash\">$ sudo pip install fabric<\/pre>\n<h2>Fabric\u3092\u4f7f\u3063\u3066\u307f\u308b<\/h2>\n<p>\u307e\u305a\u306f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306bfabfile.py\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3002\u3068\u308a\u3042\u3048\u305a<a title=\"Overview and Tutorial - Fabric 1.8.1 documentation\" href=\"http:\/\/docs.fabfile.org\/en\/1.8\/tutorial.html\" target=\"_blank\">\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb<\/a>\u306b\u6cbf\u3063\u3066\u89e6\u3063\u3066\u307f\u308c\u3070\u3069\u3093\u306a\u3082\u306e\u304b\u5206\u304b\u308b\u304b\u3068\u601d\u3046\u3002<\/p>\n<h3>\u307e\u305a\u306f\u57fa\u672c\u306e\u30b3\u30de\u30f3\u30c9(\uff1f)4\u3064\u3092\u899a\u3048\u308c\u3070OK<\/h3>\n<p>\u307e\u305a\u306f\u4ee5\u4e0b\u306e4\u3064\u306e\u30b3\u30de\u30f3\u30c9\uff08\uff0bpython\u306e\u57fa\u672c\u306e\u6587\u6cd5\uff09\u3092\u899a\u3048\u308b\u3068\u3001\u5927\u4f53\u306e\u4e8b\u306f\u51fa\u6765\u308b\u3088\u3046\u306b\u306a\u308b\u3002<\/p>\n<ul>\n<li>local : \u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u3067\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c<\/li>\n<li>run : \u30ea\u30e2\u30fc\u30c8\u74b0\u5883\u3067\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c<\/li>\n<li>put : \u30ed\u30fc\u30ab\u30eb\u304b\u3089\u30ea\u30e2\u30fc\u30c8\u306b\u30d5\u30a1\u30a4\u30eb\u3092\u30b3\u30d4\u30fc<\/li>\n<li>execute : \u5225\u306e\u30bf\u30b9\u30af\u3092\u5b9f\u884c<\/li>\n<\/ul>\n<p>\u4e0a\u306e4\u3064\u3092\u4f7f\u3063\u305f\uff08\u7c21\u7565\u5316\u3057\u305f\uff09fabfile.py\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308b\u3002<\/p>\n<pre class=\"brush: python\">from fabric.api import local, run, env\r\n\r\nenv.user = \"playuser\"\r\nenv.hosts = ['web1', 'web2']\r\n\r\ndef package():\r\n    local('play package')\r\n\r\ndef deploy():\r\n    execute(package)\r\n    put('target\/scala-2.10\/project-foo_2.10-0.1-SNAPSHOT.jar', '\/path\/to\/lib')\r\n    run('\/etc\/init.d\/play restart')<\/pre>\n<p>package\u3068deploy\u3068\u3044\u30462\u3064\u306e\u30bf\u30b9\u30af\u304c\u5b9a\u7fa9\u3055\u308c\u3001deploy\u306e\u524d\u306b\u306fpackage\u304c\u5b9f\u884c\u3055\u308c\u308b\u3002\u3059\u3054\u3044\u7c21\u5358\u306b\u30c7\u30d7\u30ed\u30a4\u306e\u30bf\u30b9\u30af\u304c\u66f8\u3051\u308b\u306e\u304c\u5206\u304b\u308b\u3068\u601d\u3046\u3002<\/p>\n<p>\u30bf\u30b9\u30af\u306e\u5b9f\u884c\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3002<\/p>\n<pre class=\"brush: bash\">$ fav deploy<\/pre>\n<h3>env\u3063\u3066\u4f55\uff1f<\/h3>\n<p>\u4e0a\u306efabfile.py\u3067\u306f\u3001env.user\u3068env.hosts\u3068\u3044\u3046\u306e\u3092\u5b9a\u7fa9\u3057\u3066\u3044\u308b\u3002env\u3068\u3044\u3046\u306e\u306fFabric\u306b\u304a\u3051\u308b\u74b0\u5883\u5909\u6570\u7684\u306a\u5f79\u5272\u306e\u30c7\u30a3\u30af\u30b7\u30e7\u30ca\u30ea\u3067\u3001env.user\u3084env.hosts\u306e\u3088\u3046\u306b\u6c7a\u3081\u3089\u308c\u305f\u5f79\u5272\u306e\u3082\u306e\u3082\u3042\u308b\u3057\u3001\u81ea\u5206\u3067\u52dd\u624b\u306b\u5b9a\u7fa9\u3059\u308b\u4e8b\u3082\u51fa\u6765\u308b\u3002<\/p>\n<p>\u30e6\u30fc\u30b6\u30fc\u5b9a\u7fa9\u306eenv\u306f\u3001\u30bf\u30b9\u30af\u9593\u3067\u60c5\u5831\u3092\u5171\u6709\u3059\u308b\u969b\u306b\u4f7f\u3046\u3002<\/p>\n<p>Fabric\u3067\u4f7f\u3046env\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u306f\u3001env.user\u3001env.hosts\u4ee5\u5916\u306b\u3082\u6ca2\u5c71\u3042\u308b\u304c\u3001\u4f7f\u3046\u3082\u306e\u3092\u5f90\u3005\u306b\u899a\u3048\u3066\u3044\u3051\u3070\u826f\u3044\u3002<\/p>\n<h2>Fabric\u3067Play!\u7528\u306e\u30c7\u30d7\u30ed\u30a4\u3092\u8a18\u8ff0<\/h2>\n<h3>env.roledefs\u3067\u8907\u6570\u30ed\u30fc\u30eb\u306e\u5b9a\u7fa9<\/h3>\n<p>\u4eca\u56de\u306fWeb\u3001DB\u3001\u30d0\u30c3\u30c1\u3067\u305d\u308c\u305e\u308c\u30b5\u30fc\u30d0\u30fc\u304c\u7570\u306a\u308a\u3001\u305d\u308c\u305e\u308c\u306b\u9055\u3063\u305f\u5185\u5bb9\u306e\u30c7\u30d7\u30ed\u30a4\u3092\u5b9f\u65bd\u3057\u305f\u3044\u3002\u305d\u3093\u306a\u6642\u306b\u4f7f\u3046\u306e\u304c\u3001env.roldedefs\u3002\u5177\u4f53\u7684\u306b\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9a\u7fa9\u3059\u308b\u3002<\/p>\n<pre class=\"brush: python\">env.roledefs = {\r\n    'web': ['web.example.com'],\r\n    'db': ['db.example.com'],\r\n    'batch': ['batch.example.com']\r\n}<\/pre>\n<p>\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9a\u7fa9\u3057\u3066\u304a\u304f\u3068\u3001<\/p>\n<pre class=\"brush: python\">@roles('web')\r\ndef web_deploy():\r\n    put('local-file.jar', 'remote-path\/')<\/pre>\n<p>web_deploy\u30bf\u30b9\u30af\u304c\u5b9f\u884c\u3055\u308c\u305f\u5834\u5408\u306b\u3001web.example.com\u306b\u5bfe\u3057\u3066\u30c7\u30d7\u30ed\u30a4\u3055\u308c\u308b\u3002<\/p>\n<h3>\u30b7\u30f3\u30dc\u30ea\u30c3\u30af\u30ea\u30f3\u30af\u4f5c\u6210\u3001\u30ed\u30fc\u30eb\u30d0\u30c3\u30af<\/h3>\n<p>Capistrano\u3060\u3068\u3001\u30c7\u30d7\u30ed\u30a4\u6642\u306breleases\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u4e0b\u306b\u30bf\u30a4\u30e0\u30b9\u30bf\u30f3\u30d7\u3067\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304c\u6398\u3089\u308c\u3001\u305d\u3053\u306b\u5bfe\u3057\u3066\u30d5\u30a1\u30a4\u30eb\u304c\u30c7\u30d7\u30ed\u30a4\u3055\u308c\u3001\u305d\u306e\u5f8c\u3001\u305d\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u5bfe\u3057\u3066current\u3068\u3044\u3046\u30b7\u30f3\u30dc\u30ea\u30c3\u30af\u30ea\u30f3\u30af\u304c\u5f35\u3089\u308c\u308b\uff08\u8a73\u3057\u304f\u306f<a title=\"Capistrano Tasks\" href=\"https:\/\/github.com\/capistrano\/capistrano\/wiki\/Capistrano-Tasks\" target=\"_blank\">\u3053\u306e\u8fba<\/a>\u3092\u53c2\u7167\uff09\u3002<\/p>\n<p>Fabric\u306e\u5834\u5408\u3001\u305d\u306e\u8fba\u306f\u624b\u52d5\u3067\u3084\u3089\u306a\u3051\u308c\u3070\u3044\u3051\u306a\u3044\u307f\u305f\u3044\u3060\u3051\u3069\u3001<a title=\"Fabric deploy script with : south migrations, rollback and maintenance page.\" href=\"https:\/\/gist.github.com\/cyberdelia\/354506\" target=\"_blank\">\u3053\u3061\u3089\u306egist<\/a>\u3092\u53c2\u8003\u306b\u3057\u305f\u3089\uff08\u3068\u3044\u3046\u304b\u307b\u307c\u305d\u306e\u307e\u307e\uff09\u7d50\u69cb\u7c21\u5358\u306b\u66f8\u3051\u305f\u3002<\/p>\n<pre class=\"brush: python\">def releases():\r\n    env.base_dir = \"\/home\/playuser\"\r\n    env.current_path = \"%(base_dir)s\/current\" % { 'base_dir':env.base_dir }\r\n    env.releases_path = \"%(base_dir)s\/releases\" % { 'base_dir':env.base_dir }\r\n    env.shared_path = \"%(base_dir)s\/shared\" % { 'base_dir':env.base_dir }\r\n\r\n    env.releases = sorted(run('ls -x %(releases_path)s' % { 'releases_path':env.releases_path }).split())\r\n    if len(env.releases) &gt;= 1:\r\n        env.current_revision = env.releases[-1]\r\n        env.current_release = \"%(releases_path)s\/%(current_revision)s\" % { 'releases_path':env.releases_path, 'current_revision':env.current_revision }\r\n    if len(env.releases) &gt; 1:\r\n        env.previous_revision = env.releases[-2]\r\n        env.previous_release = \"%(releases_path)s\/%(previous_revision)s\" % { 'releases_path':env.releases_path, 'previous_revision':env.previous_revision }\r\n\r\ndef deploy():\r\n    from time import time\r\n    env.current_release = \"%(releases_path)s\/%(time).0f\" % { 'releases_path':env.releases_path, 'time':time() }\r\n\r\n    run(\"mkdir -p %(target_dir)s\" % { 'target_dir':env.current_release })\r\n    put('local-file.jar', env.current_release)\r\n\r\ndef rollback_code():\r\n    if not env.has_key('releases'):\r\n        execute(releases)\r\n    if len(env.releases) &gt;= 2:\r\n        env.current_revision = env.releases[-1]\r\n        env.previous_revision = env.releases[-2]\r\n        env.current_release = \"%(releases_path)s\/%(current_revision)s\" % { 'releases_path':env.releases_path, 'current_revision':env.current_revision }\r\n        env.previous_release = \"%(releases_path)s\/%(previous_revision)s\" % { 'releases_path':env.releases_path, 'previous_revision':env.previous_revision }\r\n        run(\"rm %(current_path)s; ln -s %(previous_release)s %(current_path)s &amp;&amp; rm -rf %(current_release)s\" % { 'current_release':env.current_release, 'previous_release':env.previous_release, 'current_path':env.current_path })<\/pre>\n<h3>Play!\u306e\u8d77\u52d5<\/h3>\n<p>\u3053\u3053\u306fFabric\u3068\u306f\u3042\u307e\u308a\u95a2\u4fc2\u306a\u3044\u8a71\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u3001\u30d1\u30c3\u30b1\u30fc\u30b8\u3068\u304b\u8d77\u52d5\u30b9\u30af\u30ea\u30d7\u30c8\u304c\u4f5c\u6210\u3055\u308c\u308b\u3002\u8a73\u3057\u304f\u306f<a title=\"Creating a standalone version of your application | Play! framework 2.2\" href=\"http:\/\/www.playframework.com\/documentation\/2.2.x\/ProductionDist\" target=\"_blank\">play\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a>\u3092\u53c2\u7167\u3002<\/p>\n<pre class=\"brush: bash\">$ play stage<\/pre>\n<p>\u3067\u3001\u4f5c\u6210\u3055\u308c\u305ftarget\/universal\/stage\u4ee5\u4e0b\u306ebin, conf, lib\u3092\u30ea\u30e2\u30fc\u30c8\u30b5\u30fc\u30d0\u30fc\u306eshared\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30fc\u306b\u653e\u308a\u8fbc\u3080\u3002<\/p>\n<p>\u305f\u3060\u3057\u3001lib\/\u4ee5\u4e0b\u304b\u3089\u81ea\u5206\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306ejar\u30d5\u30a1\u30a4\u30eb\u3060\u3051\u306f\u53d6\u308a\u9664\u3044\u3066\u304a\u304f\u3002\u81ea\u5206\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306ejar\u30d5\u30a1\u30a4\u30eb\u306f\u3001\u6bce\u56dereleases\/(\u30bf\u30a4\u30e0\u30b9\u30bf\u30f3\u30d7)\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u30b3\u30d4\u30fc\u3055\u308c\u308b\u306e\u3067\u3002<\/p>\n<p>\u203b\u3053\u3053\u3067\u306f\u3001dependencies\u306f\u3042\u307e\u308a\u66f4\u65b0\u3055\u308c\u306a\u3044\u4e8b\u3092\u524d\u63d0\u3068\u3057\u3066\u3044\u308b\u3002<\/p>\n<p>\u3042\u3068\u306f\u3001bin\u4ee5\u4e0b\u306e\u8d77\u52d5\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5c11\u3057\u5909\u66f4\u3059\u308b\u3002\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u90e8\u5206\u3092\u3001<\/p>\n<pre class=\"brush: bash\">declare -r lib_dir=\"$(realpath \"${app_home}\/..\/lib\")\"\r\ndeclare -r app_mainclass=\"play.core.server.NettyServer\"\r\n\r\ndeclare -r app_classpath=\"$lib_dir\/projectfoo.projectfoo-1.0-SNAPSHOT.jar:$lib_dir\/3rdparty-lib.jar:.....\"<\/pre>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3059\u308b\u3002<\/p>\n<pre class=\"brush: bash\">declare -r lib_dir=\"$(realpath \"${app_home}\/..\/lib\")\"\r\ndeclare -r app_mainclass=\"play.core.server.NettyServer\"\r\ndeclare -r deploy_dir=\"$(realpath \"${app_home}\/..\/..\/current\")\" # \u8ffd\u52a0\r\n\r\ndeclare -r app_classpath=\"$deploy_dir\/projectfoo.projectfoo-1.0-SNAPSHOT.jar:$lib_dir\/3rdparty-lib.jar:.....\"<\/pre>\n<p>\u3053\u308c\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8d77\u52d5\u3067\u304d\u308b\u3002<\/p>\n<pre class=\"brush: bash\">$ shared\/bin\/projectfoo-website -Dconfig.file=shared\/conf\/application-production.conf<\/pre>\n<h3>\u30d7\u30ed\u30bb\u30b9\u306e\u505c\u6b62<\/h3>\n<p>\u3053\u3053\u307e\u3067\u6765\u308b\u3068\u3042\u3068\u3061\u3087\u3044\u3002deploy\u5f8c\u306b\u3001Play!\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u518d\u8d77\u52d5\u3057\u305f\u3044\u3002<\/p>\n<p>\u505c\u6b62\u306f\u3001RUNNING_PID\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u306b\u66f8\u304b\u308c\u3066\u3044\u308bPID\u306e\u30d7\u30ed\u30bb\u30b9\u3092kill\u3059\u308c\u3070\u826f\u3044\u306e\u3067\u3001\u3053\u3093\u306a\u611f\u3058\u3002run\u306e\u5f15\u6570\u3067shell=False\u3092\u4ed8\u3051\u3066\u304a\u304b\u306a\u3044\u3068\u3001\u30d0\u30c3\u30af\u30af\u30a9\u30fc\u30c8\u3068\u304b\u304c\u30a8\u30b9\u30b1\u30fc\u30d7\u3055\u308c\u3066\u3057\u307e\u3046\u3002<\/p>\n<pre class=\"brush: python\">def web_stop():\r\n    run(\"kill `cat %(shared_dir)s\/RUNNING_PID`\" % {\"shared_dir\":env.shared_path}, shell=False)<\/pre>\n<h3>\u30d7\u30ed\u30bb\u30b9\u3092\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9\u3067\u8d77\u52d5<\/h3>\n<p>Fabric\u3067\u30d7\u30ed\u30bb\u30b9\u3092\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9\u3067\u5b9f\u884c\u3059\u308b\u306b\u306f\u3061\u3087\u3063\u3068\u3057\u305f\u30cf\u30c3\u30af\u304c\u5fc5\u8981\u3063\u307d\u3044\u3002<\/p>\n<p>\u30dd\u30a4\u30f3\u30c8\u306f\u4ee5\u4e0b\u306e3\u70b9\u3002<\/p>\n<ul>\n<li>pty=False \u306b\u3059\u308b\u3002<\/li>\n<li>&amp;\u3092\u3064\u3051\u3066\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9\u306b\u307e\u308f\u3059\u3002<\/li>\n<li>\u6a19\u6e96\u51fa\u529b\u3001\u6a19\u6e96\u30a8\u30e9\u30fc\u51fa\u529b\u306b\u306f\u4f55\u3082\u51fa\u529b\u3057\u306a\u3044\u3002<\/li>\n<\/ul>\n<p>\u5177\u4f53\u7684\u306b\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3059\u308b\u3002<\/p>\n<pre class=\"brush: python\">def web_start():\r\n    run(\"shared\/bin\/projectfoo-website -Dconfig.file=shared\/conf\/application-production.conf &gt; \/dev\/null 2&gt;&amp;1 &amp;\", pty=False)<\/pre>\n<h2>wrapping up<\/h2>\n<p>\u4eca\u307e\u3067\u306e\u3092\u307e\u3068\u3081\u3066\u30011\u3064\u306efabfile.py\u306b\u3057\u305f\u3002\u9577\u3044\u306e\u3067gist\u306e\u65b9\u306b\u8cbc\u3063\u305f\uff08<a title=\"fabfile.py for Play! framework 2.2 multi-project settings\" href=\"https:\/\/gist.github.com\/k4200\/8502095\" target=\"_blank\">\u3053\u3061\u3089<\/a>\uff09\u3002<\/p>\n<p>Fabric\u3092\u4f7f\u3044\u59cb\u3081\u305f\u3070\u3063\u304b\uff06Python\u306f\u8a73\u3057\u304f\u306a\u3044\u306e\u3067\u3001\u76f4\u3057\u305f\u65b9\u304c\u826f\u3044\u70b9\u3068\u304b\u6307\u6458\u4e8b\u9805\u3068\u304b\u304c\u3042\u308c\u3070\u3001\u30b3\u30e1\u30f3\u30c8\u3092\u9802\u3051\u308c\u3070\u5e78\u3044\u3002<\/p>\n<h3>TODO<\/h3>\n<p>\u4eca\u5f8c\u3001\u4ee5\u4e0b\u306b\u5bfe\u5fdc\u3057\u305f\u3044\u3002<\/p>\n<ul>\n<li>dependencies\u304c\u66f4\u65b0\u3055\u308c\u305f\u6642\u306b\u3082\u3001\u7c21\u5358\u306b\u5bfe\u5fdc\u51fa\u6765\u308b\u3088\u3046\u306b\u3059\u308b\u3002<\/li>\n<li>DB migration\u306e\u4ed5\u7d44\u307f\u3002evolutions\u3063\u3066\u4f7f\u3044\u306b\u304f\u3059\u304e\u308b\u30fb\u30fb\u30fb<\/li>\n<\/ul>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>Ruby on Rails\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u7121\u3051\u308c\u3070\u3001Capistrano\u3088\u308aFabric\u306e\u65b9\u304c\u30b7\u30f3\u30d7\u30eb\u3067\u826f\u3044\u306e\u3067\u306f\uff1f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3082\u5145\u5b9f\u3057\u3066\u3044\u308b\u306e\u3067\u3001Python\u306b\u8a73\u3057\u304f\u306a\u3044\u81ea\u5206\u3067\u3082\u666e\u901a\u306b\u3084\u308a\u305f\u3044\u4e8b\u304c\u51fa\u6765\u305f\u3057\u30aa\u30cc\u30cc\u30e1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u968f\u5206\u524d\u304b\u3089\u3001\u52c9\u5f37\u304c\u3066\u3089\u500b\u4eba\u3067\u3061\u3087\u3053\u3061\u3087\u3053web\u30b5\u30a4\u30c8\u4f5c\u3063\u3066\u308b\u3002\u30c7\u30d7\u30ed\u30a4\u306fjar\u30d5\u30a1\u30a4\u30eb\u306e\u30b3\u30d4\u30fc\u3060\u3051\u3068\u306f\u8a00\u3048\u3001\u6bce\u56de\u624b\u52d5\u3067deploy\u3068\u30b5\u30fc\u30d3\u30b9\u518d\u8d77\u52d5\u3092\u3059\u308b\u306e\u306f\u3055\u3059\u304c\u306b\u9762\u5012\u306b\u306a\u3063\u3066\u304d\u305f\u306e\u3067\u3001\u30c7\u30d7\u30ed\u30a4\u3092\u81ea\u52d5\u5316\u3059\u308b\u30c4\u30fc\u30eb\u3092\u5c0e\u5165\u3059&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[8],"tags":[922,916],"class_list":["post-1353","post","type-post","status-publish","format-standard","hentry","category-8","tag-fabric","tag-play-framework"],"_links":{"self":[{"href":"https:\/\/kazu.tv\/blog\/wp-json\/wp\/v2\/posts\/1353","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kazu.tv\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kazu.tv\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kazu.tv\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kazu.tv\/blog\/wp-json\/wp\/v2\/comments?post=1353"}],"version-history":[{"count":5,"href":"https:\/\/kazu.tv\/blog\/wp-json\/wp\/v2\/posts\/1353\/revisions"}],"predecessor-version":[{"id":1358,"href":"https:\/\/kazu.tv\/blog\/wp-json\/wp\/v2\/posts\/1353\/revisions\/1358"}],"wp:attachment":[{"href":"https:\/\/kazu.tv\/blog\/wp-json\/wp\/v2\/media?parent=1353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kazu.tv\/blog\/wp-json\/wp\/v2\/categories?post=1353"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kazu.tv\/blog\/wp-json\/wp\/v2\/tags?post=1353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}