hollyさんのwiki

https://openshift.redhat.com ひさびさに試してみた。アカウントとか公開鍵とかは適当に登録しておくこと

ssh

昔はなかった気がするが、アカウント作成するとsshで直接ログインもできるようなので。自分のUIDを確認する

rhc

クライアントツール。https://openshift.redhat.com/community/get-started perl使えるところが少ないので、ここをつかう

インストール

いかんながらrubyもいれる。keychainは必須じゃないけど、いれておくとなにかと便利なのでインストール
sudo yum install rubygems git keychain
rhcをインストール
sudo gem install rhc

初期設定

setup
rhc setup

Starting Interactive Setup for OpenShift's command line interface

We'll help get you setup with just a couple of questions. You can skip this in the future by copying your config's around:

    /home/holly/.openshift/express.conf
    /home/holly/.ssh/

To connect to openshift.redhat.com enter your OpenShift login (email or Red Hat login id): <- ログインID入力
Password: <- パスワード入力

Configuration file /home/holly/.openshift/express.conf already exists, backing up to /home/holly/.openshift/express.conf.bak

Created local config file: /home/holly/.openshift/express.conf
The express.conf file contains user configuration, and can be transferred to different computers.

No SSH keys were found. We will generate a pair of keys for you.

    Created: /home/holly/.ssh/id_rsa.pub


Your public ssh key must be uploaded to the OpenShift server.  Would you like us to upload it for you? (yes/no) <- とりあえずno

You can upload your ssh key at a later time using the 'rhc sshkey' command

We will now check to see if you have the necessary client tools installed.

Checking for git ... found

Checking for your namespace ... found namespace:
    holly

Checking for applications ... none found

Below is a list of the types of application you can create: Obtaining list of cartridges (please excuse the delay)...
    * nodejs-0.6 - rhc app create -t nodejs-0.6 -a <app name>
    * zend-5.6 - rhc app create -t zend-5.6 -a <app name>
    * ruby-1.9 - rhc app create -t ruby-1.9 -a <app name>
    * jbossas-7 - rhc app create -t jbossas-7 -a <app name>
    * python-2.6 - rhc app create -t python-2.6 -a <app name>
    * jenkins-1.4 - rhc app create -t jenkins-1.4 -a <app name>
    * ruby-1.8 - rhc app create -t ruby-1.8 -a <app name>
    * jbosseap-6.0 - rhc app create -t jbosseap-6.0 -a <app name>
    * diy-0.1 - rhc app create -t diy-0.1 -a <app name>
    * php-5.3 - rhc app create -t php-5.3 -a <app name>
    * perl-5.10 - rhc app create -t perl-5.10 -a <app name>

Thank you for setting up your system.  You can rerun this at any time by calling 'rhc setup'.

ドメイン情報

domain
rhc domain

Applications in holly:

hollyapp @ http://hollyapp-holly.rhcloud.com/
=============================================
Created: 2:32 AM
Git URL: ssh://xxxxxxx@hollyapp-holly.rhcloud.com/~/git/hollyapp.git/

Cartridges:
  perl-5.10
  postgresql-8.4 - postgresql://x.x.x.x:5432/


UIDのみ出力したい場合は
rhc domain -p <pass> | grep "^Git URL:" | sed -e 's/.*ssh:\/\/\(.*\)@.*/\1/'

アプリケーション

アプリケーション作成
もちろんperlで
rhc app create -a hollyapp -t perl-5.10 -p <pass>

Creating application: hollyapp in holly
Now your new domain name is being propagated worldwide (this might take a minute)...
Checking if the application is available #1
Application hollyapp is available at: http://hollyapp-holly.rhcloud.com/
  Git URL: ssh://xxxxxxxxxxxxxx@hollyapp-holly.rhcloud.com/~/git/hollyapp.git/
Successfully created application: hollyapp


デプロイはgit経由で行うのでとりあえずcloneする
mkdir ~/openshift
cd ~/openshift
git clone ssh://xxxxxxxxxxxx@hollyapp-holly.rhcloud.com/~/git/hollyapp.git/
mojolicious
Mojolicious::Lite on OpenShiftをありがたく頂戴する
cd hollyapp
git config --global user.name "holly"
git config --global user.email "xxxxxx@xxxxx"

git rm -r perl
git commit -a -m "remove stock perl dir to prepare for Mojolicius::Lite"
git remote add upstream -m master git://github.com/degtyarev-dm/mojolicious-lite-openshift.git
git pull -s recursive -X theirs upstream master

.htaccessは変更する必要あり。psgi_appのパスはサーバの中にログインして調べるのがよい
PerlSetVar psgi_app /var/lib/stickshift/xxxx/app-root/runtime/repo/perl/index.pl

deplist.txtは以下のように記述
Time::HiRes
Mojolicious::Lite
Test::TCP
Plack::Handler::Apache2

あとはpushすればdeploy完了。deplists.txtに記載されたモジュールが自動でインストールされる
git push origin master

mojoliciousの詳細はこっちを参照

log

apacheのログをみる
rhc app tail -o "-n 100" -a hollyapp -p <pass>

cartridge

DBなど使えるようになっているみたい
一覧をみる
rhc app cartridge

List of supported embedded cartridges:

Obtaining list of cartridges (please excuse the delay)...
mongodb-2.0, cron-1.4, mysql-5.1, postgresql-8.4, haproxy-1.4, 10gen-mms-agent-0.1, phpmyadmin-3.4, metrics-0.1, rockmongo-1.1, jenkins-client-1.4

追加
postgresを追加してみる
rhc app cartridge add -c postgresql-8.4 -a hollyapp -p <pass>


RESULT:

PostgreSQL 8.4 database added.  Please make note of these credentials:

   Root User: admin
   Root Password: xxxxxx
   Database Name: hollyapp

Connection URL: postgresql://127.1.253.129:5432/

その他のサブコマンドはremove/stop/start/restart/status/reload

Wiki内検索

Menu

ここは自由に編集できるエリアです。

管理人/副管理人のみ編集できます