add production2 env for testing new servers

This commit is contained in:
Albert Yi 2018-09-21 12:47:03 -07:00
parent 4fd949ca8d
commit 897d3d3a99
8 changed files with 161 additions and 17 deletions

View File

@ -2,6 +2,10 @@
# Run: curl -L -s https://raw.githubusercontent.com/r888888888/danbooru/master/INSTALL.debian -o install.sh ; chmod +x install.sh ; ./install.sh # Run: curl -L -s https://raw.githubusercontent.com/r888888888/danbooru/master/INSTALL.debian -o install.sh ; chmod +x install.sh ; ./install.sh
export RUBY_VERSION=2.5.1
export GITHUB_INSTALL_SCRIPTS=https://raw.githubusercontent.com/r888888888/danbooru/master/script/install
export VIPS_VERSION=8.7.0
if [[ "$(whoami)" != "root" ]] ; then if [[ "$(whoami)" != "root" ]] ; then
echo "You must run this script as root" echo "You must run this script as root"
exit 1 exit 1
@ -28,20 +32,54 @@ if [[ -z "$HOSTNAME" ]] ; then
exit 1 exit 1
fi fi
export RUBY_VERSION=2.5.1 echo -n "* Enter the VLAN IP address for this server (ex: 172.16.0.1, enter nothing to skip): "
export GITHUB_INSTALL_SCRIPTS=https://raw.githubusercontent.com/r888888888/danbooru/master/script/install read VLAN_IP_ADDR
# Install packages # Install packages
echo "* Installing packages..." echo "* Installing packages..."
LIBSSL_DEV_PKG=$( verlt `lsb_release -sr` 9.0 && echo libssl-dev || echo libssl1.0-dev )
if [ -n "$(uname -a | grep Ubuntu)" ] ; then
LIBSSL_DEV_PKG=libssl-dev
else
LIBSSL_DEV_PKG=$( verlt `lsb_release -sr` 9.0 && echo libssl-dev || echo libssl1.0-dev )
fi
apt-get update apt-get update
apt-get -y install build-essential automake $LIBSSL_DEV_PKG libxml2-dev libxslt-dev ncurses-dev sudo libreadline-dev flex bison ragel memcached libmemcached-dev git curl libcurl4-openssl-dev libvips-dev libvips-tools sendmail-bin sendmail postgresql postgresql-contrib libpq-dev postgresql-server-dev-all nginx ssh coreutils ffmpeg mkvtoolnix libvips42 libvips-tools libvips-dev apt-get -y install $LIBSSL_DEV_PKG build-essential automake libxml2-dev libxslt-dev ncurses-dev sudo libreadline-dev flex bison ragel memcached libmemcached-dev git curl libcurl4-openssl-dev sendmail-bin sendmail nginx ssh coreutils ffmpeg mkvtoolnix
apt-get -y install libpq-dev postgresql-client
apt-get -y install libjpeg-turbo8-dev libexpat1-dev libgif-dev libpng-dev libexif-dev
# vrack specific stuff
if [ -n "$VLAN_IP_ADDR" ] ; then
apt-get -y install vlan
modprobe 8021q
echo "8021q" >> /etc/modules
vconfig add eno2 99
ip addr add $VLAN_IP_ADDR/24 dev eno2.99
ip link set up eno2.99
curl -L -s $GITHUB_INSTALL_SCRIPTS/vrack-cfg.yaml -o /etc/netplan/01-netcfg.yaml
fi
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
curl -sSL https://deb.nodesource.com/setup_10.x | sudo -E bash -
apt-get update
apt-get -y install nodejs yarn
apt-get remove cmdtest
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "* Error installing packages; aborting" echo "* Error installing packages; aborting"
exit 1 exit 1
fi fi
# compile and install libvips (the version in apt is too old)
cd /tmp
wget -q https://github.com/libvips/libvips/releases/download/v$VIPS_VERSION/vips-$VIPS_VERSION.tar.gz
tar xzf vips-$VIPS_VERSION.tar.gz
cd vips-$VIPS_VERSION
./configure --prefix=/usr
make install
ldconfig
# Create user account # Create user account
useradd -m danbooru useradd -m danbooru
chsh -s /bin/bash danbooru chsh -s /bin/bash danbooru
@ -58,7 +96,7 @@ fi
# Install rbenv # Install rbenv
echo "* Installing rbenv..." echo "* Installing rbenv..."
cd / cd /tmp
sudo -u danbooru git clone git://github.com/sstephenson/rbenv.git ~danbooru/.rbenv sudo -u danbooru git clone git://github.com/sstephenson/rbenv.git ~danbooru/.rbenv
sudo -u danbooru touch ~danbooru/.bash_profile sudo -u danbooru touch ~danbooru/.bash_profile
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~danbooru/.bash_profile echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~danbooru/.bash_profile

View File

@ -1,4 +1,4 @@
set :stages, %w(production development staging) set :stages, %w(production production2 development staging)
set :default_stage, "staging" set :default_stage, "staging"
set :application, "danbooru" set :application, "danbooru"
set :repo_url, "git://github.com/r888888888/danbooru.git" set :repo_url, "git://github.com/r888888888/danbooru.git"

View File

@ -1,14 +1,14 @@
FROM ruby:2.5.1-slim-stretch FROM ruby:2.5.1-slim-stretch
ENV DOCKERIZE_VERSION v0.6.1 ENV DOCKERIZE_VERSION v0.6.1
ENV VIPS_VERSION 8.6.4 ENV VIPS_VERSION 8.7.0
RUN apt-get update && \ RUN apt-get update && \
apt-get -y install wget && \ apt-get -y install wget && \
wget -q https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && \ wget -q https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && \
tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && \ tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && \
rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && \ rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && \
apt-get -y install -qq curl gnupg apt-transport-https apt-utils build-essential automake libssl-dev libxml2-dev libxslt-dev ncurses-dev sudo libreadline-dev flex bison ragel memcached libmemcached-dev git libcurl4-openssl-dev imagemagick libmagickcore-dev libmagickwand-dev sendmail-bin sendmail postgresql-client libpq-dev nginx ssh coreutils ffmpeg mkvtoolnix emacs24-nox telnet libgif-dev && \ apt-get -y install -qq curl gnupg apt-transport-https apt-utils build-essential automake libssl-dev libxml2-dev libxslt-dev ncurses-dev sudo libreadline-dev flex bison ragel memcached libmemcached-dev git libcurl4-openssl-dev sendmail-bin sendmail postgresql-client libpq-dev nginx ssh coreutils ffmpeg mkvtoolnix emacs24-nox telnet libgif-dev && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
curl -sSL https://deb.nodesource.com/setup_10.x | sudo -E bash - && \ curl -sSL https://deb.nodesource.com/setup_10.x | sudo -E bash - && \
@ -17,7 +17,7 @@ RUN apt-get update && \
apt-get remove cmdtest && \ apt-get remove cmdtest && \
apt-get clean && \ apt-get clean && \
cd /tmp && \ cd /tmp && \
wget -q https://github.com/jcupitt/libvips/releases/download/v$VIPS_VERSION/vips-$VIPS_VERSION.tar.gz && \ wget -q https://github.com/libvips/libvips/releases/download/v$VIPS_VERSION/vips-$VIPS_VERSION.tar.gz && \
tar xzf vips-$VIPS_VERSION.tar.gz && \ tar xzf vips-$VIPS_VERSION.tar.gz && \
cd vips-$VIPS_VERSION && \ cd vips-$VIPS_VERSION && \
./configure --prefix=/usr && \ ./configure --prefix=/usr && \

View File

@ -0,0 +1,96 @@
Rails.application.configure do
# Verifies that versions and hashed value of the package contents in the project's package.json
config.webpacker.check_yarn_integrity = false
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
# config.require_master_key = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Store uploaded files on the local file system (see config/storage.yml for options)
config.active_storage.service = :local
# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :error
# Prepend all log lines with the following tags.
config.log_tags = [ :request_id ]
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Use a real queuing backend for Active Job (and separate queues per environment)
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "danbooru_#{Rails.env}"
config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Use a different logger for distributed setups.
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end

View File

@ -2,7 +2,7 @@
app_path = "/var/www/danbooru2/current" app_path = "/var/www/danbooru2/current"
# Set unicorn options # Set unicorn options
worker_processes 22 worker_processes 10
timeout 180 timeout 180
#listen "127.0.0.1:9000", :tcp_nopush => true #listen "127.0.0.1:9000", :tcp_nopush => true

View File

@ -1,12 +1,12 @@
namespace :delayed_job do namespace :delayed_job do
desc "Start delayed_job process" desc "Start delayed_job process"
task :start do task :start do
on roles(:app) do on roles(:worker) do
if test("[ -d #{current_path} ]") if test("[ -d #{current_path} ]")
within current_path do within current_path do
with rails_env: fetch(:rails_env) do with rails_env: fetch(:rails_env) do
hostname = capture("hostname").strip hostname = capture("hostname").strip
execute :bundle, "exec", "script/delayed_job", "--queues=default,#{hostname}", "-n 2", "start" execute :bundle, "exec", "script/delayed_job", "--queues=default,#{hostname}", "-n 8", "start"
end end
end end
end end
@ -15,7 +15,7 @@ namespace :delayed_job do
desc "Stop delayed_job process" desc "Stop delayed_job process"
task :stop do task :stop do
on roles(:app) do on roles(:worker) do
if test("[ -d #{current_path} ]") if test("[ -d #{current_path} ]")
within current_path do within current_path do
with rails_env: fetch(:rails_env) do with rails_env: fetch(:rails_env) do
@ -28,7 +28,7 @@ namespace :delayed_job do
desc "Restart delayed_job process" desc "Restart delayed_job process"
task :restart do task :restart do
on roles(:app) do on roles(:worker) do
find_and_execute_task("delayed_job:stop") find_and_execute_task("delayed_job:stop")
find_and_execute_task("delayed_job:start") find_and_execute_task("delayed_job:start")
end end
@ -36,7 +36,7 @@ namespace :delayed_job do
desc "Kill delayed_job process" desc "Kill delayed_job process"
task :kill do task :kill do
on roles(:app) do on roles(:worker) do
procs = capture("ps -A -o pid,command").split(/\r\n|\r|\n/).grep(/delayed_job/).map(&:to_i) procs = capture("ps -A -o pid,command").split(/\r\n|\r|\n/).grep(/delayed_job/).map(&:to_i)
if procs.any? if procs.any?

View File

@ -1,7 +1,7 @@
namespace :symlink do namespace :symlink do
desc "Link the local config files" desc "Link the local config files"
task :local_files do task :local_files do
on roles(:app) do on roles(:app, :worker) do
execute :ln, "-s", "#{deploy_to}/shared/config/danbooru_local_config.rb", "#{release_path}/config/danbooru_local_config.rb" execute :ln, "-s", "#{deploy_to}/shared/config/danbooru_local_config.rb", "#{release_path}/config/danbooru_local_config.rb"
execute :ln, "-s", "#{deploy_to}/shared/config/database.yml", "#{release_path}/config/database.yml" execute :ln, "-s", "#{deploy_to}/shared/config/database.yml", "#{release_path}/config/database.yml"
if test("[ -f #{deploy_to}/shared/config/newrelic.yml ]") if test("[ -f #{deploy_to}/shared/config/newrelic.yml ]")
@ -12,7 +12,7 @@ namespace :symlink do
desc "Link the local directories" desc "Link the local directories"
task :directories do task :directories do
on roles(:app) do on roles(:app, :worker) do
execute :rm, "-f", "#{release_path}/public/data" execute :rm, "-f", "#{release_path}/public/data"
execute :ln, "-s", "#{deploy_to}/shared/data", "#{release_path}/public/data" execute :ln, "-s", "#{deploy_to}/shared/data", "#{release_path}/public/data"
execute :mkdir, "-p", "#{release_path}/public/cache" execute :mkdir, "-p", "#{release_path}/public/cache"

View File

@ -0,0 +1,10 @@
network:
version: 2
renderer: networkd
ethernets:
eno2: {}
vlans:
eno2.99:
id: 99
link: eno2
addresses: [172.16.0.1]