LoginSignup
1
1

More than 5 years have passed since last update.

すごく荒いDerbyJSのインストール方法

Last updated at Posted at 2015-10-15

概要

リアルタイムコラボレーションが出来るフレームワークDerbyJSを試す。
MongoDB&Redisをインストールした上で、本体(サンプル)が動作することを確認する。

インストール

前提

  • CentOS7(x64)

インストールするソフトウェア

  • nvm 0.12.7 => Node.js & npm
  • MongoDB 2.6
  • Redis 2.4
  • DerbyJS 0.6 alpha alpha版であるが、安定しているらしい。

下記は、古い可能性があるため、間違っていたら、ご連絡ください。

MongoDB インストール ※公式

console
$ sudo vim /etc/yum.repos.d/mongodb.repo
[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1
$ ls -l /etc/yum.repos.d/
 : 
-rw-r--r--. 1 root root  122  7月  5 01:49 mongodb.repo #<=インストール確認
$ sudo yum -y update
$ sudo yum -y install mongodb-org mongodb-org-server
 :
インストール:
  mongodb-org.x86_64 0:2.6.10-1       mongodb-org-server.x86_64 0:2.6.10-1      
 :
完了しました!
$ sudo systemctl start mongod
$ sudo systemctl status mongod
 : 
mongod.service - SYSV: Mongo is a scalable, document-oriented database.
 : 
   Active: active (running) since 火 2015-07-07 15:36:15 EDT; 7s ago
 : 
# 常駐起動設定(CentOS7のネイティブデーモンではないため、chkconfigを使用する。)
$ sudo chkconfig mongod on
# リッスンポート確認
$ sudo ss -nlp|grep mongod
u_str  LISTEN     0      128    /tmp/mongodb-27017.sock 54410                 * 0     users:(("mongod",4967,9))
tcp    LISTEN     0      128            127.0.0.1:27017                 *:*      users:(("mongod",4967,8))

Redis インストール

console
# wget インストール
$ sudo yum install wget
# EPEL インストール
$ sudo wget -r --no-parent -A 'epel-release-*.rpm' http://dl.fedoraproject.org/pub/epel/7/x86_64/e/
$ sudo rpm -Uvh dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-*.rpm
$ ls -l /etc/yum.repos.d/
 : 
-rw-r--r--. 1 root root  957 11月 25  2014 epel.repo #<=インストール確認
 : 
$ sudo yum -y install redis
 : 
インストール:
  redis.x86_64 0:2.8.19-2.el7                                                   
 :
完了しました!
$ sudo systemctl start redis.service
$ sudo systemctl status redis.service
redis.service - Redis persistent key-value database
:
   Active: active (running) since 火 2015-07-07 16:14:53 EDT; 18s ago
:
# 設定ファイル
# 1. /etc/redis.conf
# 2. /etc/redis-sentinel.conf
# 通信確認
$ redis-cli ping
PONG
# 常駐起動設定
$ sudo systemctl enable redis.service
# リッスンポート確認
$ sudo ss -nlp|grep redis
tcp    LISTEN     0      128            127.0.0.1:6379                  *:*      users:(("redis-server",5207,4))

サンプルにて動作確認

console
# npmがインストールされていない場合
$ sudo yum -y install npm
 :
インストール:
  npm.noarch 0:1.3.6-5.el7
 :
# Githubからサンプルダウンロード
$ cd ~
$ git clone https://github.com/derbyjs/derby-examples.git
Cloning into 'derby-examples'...
remote: Counting objects: 15138, done.
remote: Total 15138 (delta 0), reused 0 (delta 0), pack-reused 15138
Receiving objects: 100% (15138/15138), 23.49 MiB | 734.00 KiB/s, done.
Resolving deltas: 100% (4504/4504), done.
$ cd ~/derby-examples
$ npm install

# 実行
$ cd ~/derby-examples/directory
$ node server.js
Master pid  18817
18819 listening. Go to: http://localhost:8004/

# 【Appendix】SELinux無効
# 外部から閲覧できない場合は下記を実行する。
$ sudo getenforce
Enforcing
$ sudo setenforce 0
$ sudo getenforce
Permissive
$ sudo vi /etc/sysconfig/selinux
SELINUX=disabled #<=システム起動時にSELinuxを無効化
# ファイアウォール無効化
$ sudo systemctl stop firewalld
$ sudo systemctl disable firewalld
$ sudo systemctl status firewalld
firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled)
   Active: inactive (dead) <=停止確認
 : 

常駐化

forever(=node.jsスクリプトをデーモン化するツール)をインストールする。

手動起動

console
# foreverをインストール
$ sudo npm install -g forever
# Derbyを起動(起動迄若干時間がかかる。)
$ forever start /vagrant/derby-examples/directory/server.js 
warn:    --minUptime not set. Defaulting to: 1000ms
warn:    --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
info:    Forever processing file: server.js
# 起動確認
$ forever list
info:    Forever processes running
data:        uid  command       script    forever pid  id logfile                         uptime      
data:    [0] NZVZ /usr/bin/node server.js 7315    7646    /home/vagrant/.forever/NZVZ.log 0:0:0:3.599 
# 停止
$ forever stop 0
info:    Forever stopped process:
    uid  command       script    forever pid  id logfile                         uptime      
[0] NZVZ /usr/bin/node server.js 7315    8142    /home/vagrant/.forever/NZVZ.log 0:0:0:5.376 
# 停止確認
[vagrant@localhost directory]$ forever list
info:    No forever processes running

OS起動時自動起動

console
# ▪︎普通のLinux環境の場合
$ sudo vi /etc/rc.d/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

touch /var/lock/subsys/local
#Derby Demostration
forever start /vagrant/derby-examples/directory/server.js 

Vagrantの場合

Derby インストール(動作確認)

console
# install derby
npm install -g derby@~0.6 -S
npm install -g derby-starter -S
# install yeoman
$ sudo npm install -g yo
# install the generator
$ sudo npm install -g generator-derby

# プロジェクトの新規作成&動作確認
$ mkdir myapp
$ cd myapp
# create a javascript based app:
$ yo derby
# or create a coffeescript based app:
$ yo derby --coffee
$ npm start
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1