LoginSignup
0
1

More than 5 years have passed since last update.

CentOS7にRealm Object Serverをインストールする

Posted at

1.8.3からマイグレーションするために、マイグレーション先のRealm Object Serverを新規セットアップしたときのログです。

ユーザー作成

# useradd ros
# passwd ros

rosユーザーで作業

# su - ros

ROSインストール(公式サイトより)

$ curl -s https://raw.githubusercontent.com/realm/realm-object-server/master/install.sh | bash

HOGEとしてプロジェクト作成

$ ros init HOGE

起動確認

$ cd HOGE
$ npm start

デーモン化(公式サイトより)

$ npm install -g pm2
  • typescriptのインストール(ROSプロジェクトがtypescriptなので)
$ pm2 install typescript
  • 起動
$ pm2 start src/index.ts --name HOGE
[PM2] Starting /home/ros/HOGE/src/index.ts in fork_mode (1 instance)
[PM2] Done.
┌──────────┬────┬──────┬───────┬────────┬─────────┬────────┬─────┬───────────┬───────┬──────────┐
│ App name │ id │ mode │ pid   │ status │ restart │ uptime │ cpu │ mem       │ user  │ watching │
├──────────┼────┼──────┼───────┼────────┼─────────┼────────┼─────┼───────────┼───────┼──────────┤
│ HOGE     │ 0  │ fork │ 16910 │ online │ 0       │ 0s     │ 99% │ 15.3 MB   │ ros   │ disabled │
└──────────┴────┴──────┴───────┴────────┴─────────┴────────┴─────┴───────────┴───────┴──────────┘
 Use `pm2 show <id|name>` to get more details about an app
  • 確認
$ pm2 show 0
 Describing process with id 0 - name HOGE
┌───────────────────┬───────────────────────────────────────────────────────────────────────────────────────┐
│ status            │ online                                                                                │
│ name              │ HOGE                                                                                  │
│ restarts          │ 0                                                                                     │
│ uptime            │ 7s                                                                                    │
│ script path       │ /home/ros/HOGE/src/index.ts                                                           │
│ script args       │ N/A                                                                                   │
│ error log path    │ /home/ros/.pm2/logs/HOGE-error-0.log                                                  │
│ out log path      │ /home/ros/.pm2/logs/HOGE-out-0.log                                                    │
│ pid path          │ /home/ros/.pm2/pids/HOGE-0.pid                                                        │
│ interpreter       │ /home/ros/.nvm/versions/node/v8.11.1/lib/node_modules/pm2/node_modules/.bin/ts-node   │
│ interpreter args  │ N/A                                                                                   │
│ script id         │ 0                                                                                     │
│ exec cwd          │ /home/ros/HOGE                                                                        │
│ exec mode         │ fork_mode                                                                             │
│ node.js version   │ 8.11.1                                                                                │
│ watch & reload    │ ✘                                                                                     │
│ unstable restarts │ 0                                                                                     │
│ created at        │ 2018-04-24T06:01:01.630Z                                                              │
└───────────────────┴───────────────────────────────────────────────────────────────────────────────────────┘
 Code metrics value
┌─────────────────┬──────────┐
│ Loop delay      │ 387.33ms │
│ Active requests │ 0        │
│ Active handles  │ 10       │
└─────────────────┴──────────┘
 Add your own code metrics: http://bit.ly/code-metrics
 Use `pm2 logs HOGE [--lines 1000]` to display logs
 Use `pm2 monit` to monitor CPU and Memory usage HOGE
  • 自動起動化
$ pm2 startup
[PM2] Init System found: systemd
[PM2] To setup the Startup Script, copy/paste the following command:
sudo env PATH=$PATH:/home/ros/.nvm/versions/node/v8.11.1/bin /home/ros/.nvm/versions/node/v8.11.1/lib/node_modules/pm2/bin/pm2 startup systemd -u ros --hp /home/ros

$ sudo env PATH=$PATH:/home/ros/.nvm/versions/node/v8.11.1/bin /home/ros/.nvm/versions/node/v8.11.1/lib/node_modules/pm2/bin/pm2 startup systemd -u ros --hp /home/ros
[sudo] t_shimada のパスワード:

                        -------------

__/\\\\\\\\\\\\\____/\\\\____________/\\\\____/\\\\\\\\\_____
 _\/\\\/////////\\\_\/\\\\\\________/\\\\\\__/\\\///////\\\___
  _\/\\\_______\/\\\_\/\\\//\\\____/\\\//\\\_\///______\//\\\__
   _\/\\\\\\\\\\\\\/__\/\\\\///\\\/\\\/_\/\\\___________/\\\/___
    _\/\\\/////////____\/\\\__\///\\\/___\/\\\________/\\\//_____
     _\/\\\_____________\/\\\____\///_____\/\\\_____/\\\//________
      _\/\\\_____________\/\\\_____________\/\\\___/\\\/___________
       _\/\\\_____________\/\\\_____________\/\\\__/\\\\\\\\\\\\\\\_
        _\///______________\///______________\///__\///////////////__


                          Community Edition

            Production Process Manager for Node.js applications
                     with a built-in Load Balancer.


                Start and Daemonize any application:
                $ pm2 start app.js

                Load Balance 4 instances of api.js:
                $ pm2 start api.js -i 4

                Monitor in production:
                $ pm2 monitor

                Make pm2 auto-boot at server restart:
                $ pm2 startup

                To go further checkout:
                http://pm2.io/


                        -------------

[PM2] Init System found: systemd
Platform systemd
Template
[Unit]
Description=PM2 process manager
Documentation=https://pm2.keymetrics.io/
After=network.target

[Service]
Type=forking
User=ros
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
Environment=PATH=/home/ros/.nvm/versions/node/v8.11.1/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
Environment=PM2_HOME=/home/ros/.pm2
PIDFile=/home/ros/.pm2/pm2.pid

ExecStart=/home/ros/.nvm/versions/node/v8.11.1/lib/node_modules/pm2/bin/pm2 resurrect
ExecReload=/home/ros/.nvm/versions/node/v8.11.1/lib/node_modules/pm2/bin/pm2 reload all
ExecStop=/home/ros/.nvm/versions/node/v8.11.1/lib/node_modules/pm2/bin/pm2 kill

[Install]
WantedBy=multi-user.target

Target path
/etc/systemd/system/pm2-ros.service
Command list
[ 'systemctl enable pm2-ros',
  'systemctl start pm2-ros',
  'systemctl daemon-reload',
  'systemctl status pm2-ros' ]
[PM2] Writing init configuration in /etc/systemd/system/pm2-ros.service
[PM2] Making script booting at startup...
>>> Executing systemctl enable pm2-ros
Created symlink from /etc/systemd/system/multi-user.target.wants/pm2-ros.service to /etc/systemd/system/pm2-ros.service.
[DONE]
>>> Executing systemctl start pm2-ros
[DONE]
>>> Executing systemctl daemon-reload
[DONE]
>>> Executing systemctl status pm2-ros
● pm2-ros.service - PM2 process manager
   Loaded: loaded (/etc/systemd/system/pm2-ros.service; enabled; vendor preset: disabled)
   Active: active (running) since 火 2018-04-24 15:07:53 JST; 71ms ago
     Docs: https://pm2.keymetrics.io/
 Main PID: 16359 (PM2 v2.10.2: Go)
   CGroup: /system.slice/pm2-ros.service
           ‣ 16359 PM2 v2.10.2: God Daemon (/home/ros/.pm2)

 4月 24 15:07:53 goro-tsukiyama systemd[1]: Starting PM2 process manager...
 4月 24 15:07:53 goro-tsukiyama.com pm2[17031]: [PM2] Resurrecting
 4月 24 15:07:53 goro-tsukiyama.com pm2[17031]: [PM2] Restoring processes located in /home/ros/.pm2/dump.pm2
 4月 24 15:07:53 goro-tsukiyama.com pm2[17031]: [PM2][ERROR] Failed to read dump file in /home/ros/.pm2/dump.pm2
 4月 24 15:07:53 goro-tsukiyama.com pm2[17031]: [PM2] Restoring processes located in /home/ros/.pm2/dump.pm2
 4月 24 15:07:53 goro-tsukiyama.com pm2[17031]: [PM2][ERROR] Failed to read dump file in /home/ros/.pm2/dump.pm2.bak
 4月 24 15:07:53 goro-tsukiyama.com pm2[17031]: [PM2][ERROR] No processes saved; DUMP file doesn't exist
 4月 24 15:07:53 goro-tsukiyama.com systemd[1]: Started PM2 process manager.
[DONE]
+---------------------------------------+
[PM2] Freeze a process list on reboot via:
$ pm2 save

[PM2] Remove init script via:
$ pm2 unstartup systemd
  • サービスの有効化
$ sudo systemctl enable pm2-ros.service
0
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
0
1