mirror of
https://gitlab.com/depesz/explain.depesz.com.git
synced 2024-11-28 08:58:52 +02:00
commit
1b7ad1f9dd
26
README.md
26
README.md
@ -4,6 +4,32 @@ explain.depesz.com
|
||||
Setup
|
||||
==================
|
||||
|
||||
There are three ways to install your own copy:
|
||||
|
||||
* Using Vagrant [ VirtualBox machine, fully automated ]
|
||||
* Calling `puppet apply`
|
||||
* Manually
|
||||
|
||||
First get the source code:
|
||||
|
||||
git clone https://github.com/pkorobeinikov/explain.depesz.com.git
|
||||
|
||||
## Vagrant setup
|
||||
|
||||
WARNING: first call `vagrant up` fetches ~400MB of vbox image from the Internet.
|
||||
|
||||
1. Call `vagrant up`
|
||||
|
||||
Point your browser on http://192.168.44.55 (or use `/etc/hosts` entry explain.depesz.loc)
|
||||
|
||||
## Puppet setup
|
||||
|
||||
1. Install puppet on your machine, e.g. Debian installation described [here](https://docs.puppetlabs.com/guides/install_puppet/install_debian_ubuntu.html).
|
||||
2. Open explain.pp and fix line 5 with correct project dir value
|
||||
3. Call `sudo puppet apply --logdest console explain.pp` on your working copy directory.
|
||||
|
||||
## Manual setup
|
||||
|
||||
1) Mojolicious
|
||||
|
||||
You have to have Mojolicious installed on your server. Mojolicious is a web framework for Perl.
|
||||
|
23
Vagrantfile
vendored
Normal file
23
Vagrantfile
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
|
||||
VAGRANTFILE_API_VERSION = "2"
|
||||
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
config.vm.box = "ubuntu/trusty64"
|
||||
config.vm.network "private_network", ip: "192.168.44.55"
|
||||
|
||||
config.vm.provider "virtualbox" do |vb|
|
||||
vb.customize ["modifyvm", :id, "--memory", "1024"]
|
||||
end
|
||||
|
||||
config.vm.provision "puppet" do |puppet|
|
||||
puppet.options = "--verbose --debug"
|
||||
puppet.manifests_path = "."
|
||||
puppet.manifest_file = "explain.pp"
|
||||
puppet.facter = {
|
||||
"use_vagrant" => true
|
||||
}
|
||||
end
|
||||
end
|
@ -4,8 +4,9 @@
|
||||
"secret" : "|Erp--Wjgb)+eiB/|H=|V7!#+M|L{a8=J2|pd+N1=M|&pJWq|M&,f3q^XS",
|
||||
|
||||
"database" : {
|
||||
"dsn" : "dbi:Pg:database=depesz_explain;host=127.0.0.1;port=5930",
|
||||
"username" : "depesz_explain",
|
||||
"dsn" : "dbi:Pg:database=explain;host=127.0.0.1;port=5432",
|
||||
"username" : "explain",
|
||||
"password" : "explain",
|
||||
"options" : {
|
||||
"auto_commit" : 1,
|
||||
"pg_server_prepare" : 0,
|
||||
@ -23,6 +24,6 @@
|
||||
"hypnotoad" : {
|
||||
"listen" : ["http://*:12004"],
|
||||
"workers" : 2,
|
||||
"pid_file" : "/home/depesz/sites/explain.depesz.com.pid"
|
||||
"pid_file" : "/var/run/explain.depesz.com.pid"
|
||||
}
|
||||
}
|
||||
|
111
explain.pp
Normal file
111
explain.pp
Normal file
@ -0,0 +1,111 @@
|
||||
# Unfortunately there is no way to automatically detect current project directory
|
||||
if $use_vagrant {
|
||||
$PROJECT_DIR = '/vagrant'
|
||||
} else {
|
||||
fail('Replace this line with correct $PROJECT_DIR value assignment.')
|
||||
}
|
||||
|
||||
|
||||
# We need to order provision commands [ https://docs.puppetlabs.com/learning/ordering.html ]
|
||||
Exec['update_pkgs_index']->
|
||||
Package['curl'] ->
|
||||
Package['postgresql-9.3'] ->
|
||||
Package['libexpat1-dev'] ->
|
||||
Package['libpq-dev'] ->
|
||||
Exec['install_cpanm']->
|
||||
Exec['install_cpanm_dbi']->
|
||||
Exec['install_cpanm_dbd_pg']->
|
||||
Exec['install_cpanm_date_simple']->
|
||||
Exec['install_cpanm_mail_sender']->
|
||||
Exec['install_cpanm_email_valid']->
|
||||
Exec['install_cpanm_pg_explain']->
|
||||
Exec['install_cpanm_mojolicious']->
|
||||
Exec['createuser']->
|
||||
Exec['createdb']->
|
||||
Exec['psql_create']->
|
||||
Exec['psql_apply_patches']->
|
||||
Exec['psql_grant']->
|
||||
Exec['run_daemon']
|
||||
|
||||
|
||||
Exec {
|
||||
path => [
|
||||
'/usr/local/bin',
|
||||
'/usr/bin',
|
||||
'/bin'],
|
||||
logoutput => true,
|
||||
}
|
||||
|
||||
|
||||
exec { 'update_pkgs_index': command => 'apt-get update' }
|
||||
|
||||
exec { 'install_cpanm': command => 'curl -L http://cpanmin.us | perl - --self-upgrade' }
|
||||
exec { 'install_cpanm_dbi': command => 'cpanm --notest DBI' }
|
||||
exec { 'install_cpanm_dbd_pg': command => 'cpanm --notest DBD::Pg' }
|
||||
exec { 'install_cpanm_date_simple': command => 'cpanm --notest Date::Simple' }
|
||||
exec { 'install_cpanm_mail_sender': command => 'cpanm --notest Mail::Sender' }
|
||||
exec { 'install_cpanm_email_valid': command => 'cpanm --notest Email::Valid' }
|
||||
exec { 'install_cpanm_pg_explain': command => 'cpanm --notest Pg::Explain', timeout => 600 } # Takes about 450-500 secs.
|
||||
exec { 'install_cpanm_mojolicious': command => 'cpanm --notest Mojolicious' }
|
||||
|
||||
exec { 'createuser': command => 'sudo -u postgres psql -c "create role explain with login password \'explain\'"' }
|
||||
exec { 'createdb': command => 'sudo -u postgres createdb -E utf8 -O explain explain' }
|
||||
|
||||
exec { 'psql_create':
|
||||
command => sprintf("sudo -u postgres psql -d explain < %s/sql/create.sql", $PROJECT_DIR)
|
||||
}
|
||||
exec { 'psql_apply_patches':
|
||||
command => sprintf("ls -1 %s/sql/patch-???.sql | sort | xargs -n1 sudo -u postgres psql -d explain -q -f", $PROJECT_DIR)
|
||||
}
|
||||
exec { 'psql_grant':
|
||||
command => 'sudo -u postgres psql -d explain -c "grant all on plans, users to explain;"'
|
||||
}
|
||||
|
||||
exec { 'run_daemon': command => sprintf("hypnotoad %s/explain.pl > /dev/null 2> /dev/null &", $PROJECT_DIR) }
|
||||
|
||||
|
||||
package { 'curl': # required by cpanminus installation
|
||||
ensure => installed
|
||||
}
|
||||
|
||||
package { 'postgresql-9.3':
|
||||
ensure => installed
|
||||
}
|
||||
|
||||
package { 'libexpat1-dev': # required by XML::Parser
|
||||
ensure => installed
|
||||
}
|
||||
|
||||
package { 'libpq-dev': # required by DBD::Pg
|
||||
ensure => installed
|
||||
}
|
||||
|
||||
package { 'nginx':
|
||||
ensure => installed
|
||||
}
|
||||
|
||||
|
||||
file { '/etc/nginx/conf.d/explain.conf':
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
content => '
|
||||
server {
|
||||
listen 80;
|
||||
server_name explain.depesz.loc;
|
||||
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:12004;
|
||||
}
|
||||
}
|
||||
',
|
||||
notify => Service['nginx'],
|
||||
require => Package['nginx'],
|
||||
}
|
||||
|
||||
|
||||
service { 'nginx':
|
||||
ensure => running,
|
||||
enable => true,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
}
|
Loading…
Reference in New Issue
Block a user