OpenShift OnlineでMojolicious::Liteを動かしてみたい!

OpenShift Online

OpenShift Onlineは、RedHatが提供するPaaSで、Java,PHP,Python,Ruby,Perl,Node.jsなどのプログラミング言語MySQL,PostgreSQL,MongoDBのデータベースを利用できます。
Gearと言う名称がインスタンスの単位で、Free Planを選択すると3 Small Gearsまで無料で使えます。
もちろんFree Planはノーサポートですが、無料で使えるのですしマジリスペクトですよね!

ちなみに、1 Small Gearの中身はMemory 512MB、Storage 1GBになっています。



会員登録して、Create Applicationをクリック。
Perl 5.10を選択します。

あとはPublic URLを入力すれば環境が完成です。簡単!


gem install rhc


rhc setup


OpenShift Client Tools (RHC) Setup Wizard

This wizard will help you upload your SSH keys, set your application namespace, and check that other programs like Git are properly installed.

Login to
Password: ********

OpenShift can create and store a token on disk which allows to you to access the server without using your password. The key is stored in your home directory and should
be kept secret. You can delete the key at any time by running 'rhc logout'.
Generate a token now? (yes|no) yes
Generating an authorization token for this client ... lasts about 22 hours

Saving configuration to /Users/otaku/.openshift/express.conf ... done

Your public SSH key must be uploaded to the OpenShift server to access code. Upload now? (yes|no) yes

Since you do not have any keys associated with your OpenShift account, your new key will be uploaded as the 'default' key.

Uploading key 'default' ... done

Checking for git ... found git

Checking common problems .. done

Checking your namespace ... sample

Checking for applications ... found 1


You are using 1 of 3 total gears
The following gear sizes are available to you: small

Your client tools are now configured.




Getting started:
  setup              Connects to OpenShift and sets up your keys and domain
  create-app         Create an application
  apps               List all your applications
  cartridges         List available cartridges
  add-cartridge      Add a cartridge to your application
  server             Display information about the status of the OpenShift service.
  logout             End the current session

Working with apps:
  tail               Tail the logs of an application
  port-forward       Forward remote ports to the workstation
  threaddump         Trigger a thread dump for JBoss and Ruby apps
  snapshot           Save the current state of your application locally
  git-clone          Clone and configure an application's repository locally

Management commands:
  account            Display details about your OpenShift account
  alias              Add or remove a custom domain name for an app
  app                Commands for creating and managing applications
  authorization      Show the authorization tokens for your account
  cartridge          Manage your application cartridges
  domain             Add or rename the container for your apps
  sshkey             Add and remove keys for Git and SSH


git clone ssh://
cd momoclo/


perl/ For not-externally exposed perl code
libs/ Additional libraries
misc/ For not-externally exposed perl code
.openshift/ Location for OpenShift specific files
action_hooks/ See the Action Hooks documentation [1]
markers/ See the Markers section [2]




#!/usr/bin/env perl
use strict;
use warnings;
use Mojolicious::Lite;

# Route with placeholder
get '/' => sub {
  my $self = shift;
  $self->render(text => "Yes! Yes! We are the ももいろクローバー れに かなこ しおり あやか ももか");

# Start the Mojolicious command system

ローカル環境で表示できることを確認したら、OpenShift Onlineにデプロイしてみましょう。

git add .
git commit -m 'Initial Commit'
git push

Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 570 bytes, done.
Total 4 (delta 2), reused 0 (delta 0)
remote: Waiting for stop to finish
remote: --> Working on Mojolicious::Lite
remote: Fetching ... OK
remote: Configuring Mojolicious-4.16 ... OK
remote: Building Mojolicious-4.16 ... OK
remote: Successfully installed Mojolicious-4.16
remote: 1 distribution installed
remote: skipping R/RJ/RJBS/perl-5.18.0.tar.gz
remote: skipping R/RJ/RJBS/perl-5.18.0.tar.gz
master -> master

これで動くはずだったんだけど、Internal Server Error〜(;´Д`)

rhc tail momoclo

管理ツールからログを確認してみると、[error] Can't locate Time/ in @INCと表示されていました。

use Time::HiRes;


Herokuでも頑張って設定すればPerl動くみたいですけど、デフォルトで対応してくれているOpenShift Online、なかなかいいのではないでしょうか。まぁ、Herokuのように色んなアドオン使えるようにならないとしんどいですが。