3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AIIT(産業技術大学院大学)Advent Calendar 2017

Day 4

Amon2をさくらVPSで動かす

Last updated at Posted at 2017-12-03

ネットで調べたら古い情報も多くて困ったので...

#やりたいこと

  • Amon2を独自ドメインかつさくらVPSで動かす

#環境

  • Ubuntu16.04
  • Apache/2.4.18

#前提

  • hogeユーザーで行う
  • Perlの環境構築Amon2入門で、Hello Amon2まで表示されている.
  • 上記URLと同様にカレントにSchedulerがある.

#作成

scheduler.shを作成する

#!/bin/bash
export PATH="$HOME/.plenv/bin:$PATH"
eval "$(plenv init -)"
exec plenv exec carton exec plackup script/scheduler-server

##Supervisorの設定
##Supervisorのインストール

pip install supervisor

とりあえずPython2.x系で動いてます。

##ディレクトリの作成

mkdir /var/log/supervisord
mkdir /etc/supervisord.d

###supervisord.confの作成

/etc/supervisord.conf
[unix_http_server]
file=/var/run/supervisor.sock

[supervisord]
logfile=/var/log/supervisord.log
loglevel=debug
pidfile=/var/run/supervisord.pid
nodaemon=false
minfds=1024
minprocs=200
environment=SHELL="/bin/sh"

[supervisorctl]
serverurl=unix:///var/run/supervisor.sock
history_file=~/.sc_history

[include]
files=/etc/supervisord.d/*.ini

[rpcinterface:supervisor]
supervisor.rpcinterface_factory=supervisor.rpcinterface:make_main_rpcinterface

###supervisord.iniファイルの作成

/etc/supervisord.d/supervisord.ini
[group:supervisord]
programs=schedulersupervisord.ini 

[program:scheduler]
numprocs=1
autostart=true
autorestart=true
startsecs=5
user=hoge
redirect_stderr=true
stdout_logfile=/var/log/supervisord/scheduler_out.log
stdout_logfile_maxbytes=0
stdout_logfile_backups=0
stderr_logfile=/var/log/supervisord/scheduler_err.log
stderr_logfile_maxbytes=0
stderr_logfile_backups=0
#environment=HOME="/home/hoge/Scheduler",USER="xxxx", PATH="$HOME/.plenv/bin:$PATH"
directory=/home/hoge/Scheduler/
command=bash /home/hoge/Scheduler/scheduler.sh

###apacheの設定

/etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /home/hoge/Scheduler/

    ProxyPass / http://[取得した独自ドメイン].com:5000/
    ProxyPassReverse / http://[取得した独自ドメイン].com:5000/

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www\.xxxxxn\.com$
    RewriteRule ^/(.*) http://[取得した独自ドメイン].com/$1 [R=301,L]
</VirtualHost>

Hello Amon2 :)

sudo supervisorctl reload
sudo supervisorctl stop
sudo supervisorctl start

あとはこの辺で起動して独自ドメインでアクセスすると、Hello Amon2が表示されます :)

#参考
Amon2 アプリのデプロイ
Supervisorでamon2アプリのデーモン化 with plenv
SuperVisor導入(基本編)
supervisorctlについて調べてみた

3
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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?