\documentclass[DIV=13,%
BCOR=0mm,%
headinclude=false,%
footinclude=false,open=any,%
fontsize=10pt,%
oneside,%
paper=a5]%
{scrbook}
\usepackage[noautomatic]{imakeidx}
\usepackage{microtype}
\usepackage{graphicx}
\usepackage{alltt}
\usepackage{verbatim}
\usepackage[shortlabels]{enumitem}
\usepackage{tabularx}
\usepackage[normalem]{ulem}
\def\hsout{\bgroup \ULdepth=-.55ex \ULset}
% https://tex.stackexchange.com/questions/22410/strikethrough-in-section-title
% Unclear if \protect \hsout is needed. Doesn't looks so
\DeclareRobustCommand{\sout}[1]{\texorpdfstring{\hsout{#1}}{#1}}
\usepackage{wrapfig}
% avoid breakage on multiple
and avoid the next [] to be eaten
\newcommand*{\forcelinebreak}{\strut\\*{}}
\newcommand*{\hairline}{%
\bigskip%
\noindent \hrulefill%
\bigskip%
}
% reverse indentation for biblio and play
\newenvironment*{amusebiblio}{
\leftskip=\parindent
\parindent=-\parindent
\smallskip
\indent
}{\smallskip}
\newenvironment*{amuseplay}{
\leftskip=\parindent
\parindent=-\parindent
\smallskip
\indent
}{\smallskip}
\newcommand*{\Slash}{\slash\hspace{0pt}}
% http://tex.stackexchange.com/questions/3033/forcing-linebreaks-in-url
\PassOptionsToPackage{hyphens}{url}\usepackage[hyperfootnotes=false,hidelinks,breaklinks=true]{hyperref}
\usepackage{bookmark}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{english}
\setmainfont{texgyrepagella-regular.otf}[Script=Latin,%
Ligatures=TeX,%
Path=/usr/share/texmf/fonts/opentype/public/tex-gyre/,%
BoldFont=texgyrepagella-bold.otf,%
BoldItalicFont=texgyrepagella-bolditalic.otf,%
ItalicFont=texgyrepagella-italic.otf]
\setmonofont{cmuntt.ttf}[Script=Latin,%
Ligatures=TeX,%
Scale=MatchLowercase,%
Path=/usr/share/fonts/truetype/cmu/,%
BoldFont=cmuntb.ttf,%
BoldItalicFont=cmuntx.ttf,%
ItalicFont=cmunit.ttf]
\setsansfont{cmunss.ttf}[Script=Latin,%
Ligatures=TeX,%
Scale=MatchLowercase,%
Path=/usr/share/fonts/truetype/cmu/,%
BoldFont=cmunsx.ttf,%
BoldItalicFont=cmunso.ttf,%
ItalicFont=cmunsi.ttf]
\newfontfamily\englishfont{texgyrepagella-regular.otf}[Script=Latin,%
Ligatures=TeX,%
Path=/usr/share/texmf/fonts/opentype/public/tex-gyre/,%
BoldFont=texgyrepagella-bold.otf,%
BoldItalicFont=texgyrepagella-bolditalic.otf,%
ItalicFont=texgyrepagella-italic.otf]
\renewcommand*{\partpagestyle}{empty}
% global style
\pagestyle{plain}
\usepackage{indentfirst}
% remove the numbering
\setcounter{secnumdepth}{-2}
% remove labels from the captions
\renewcommand*{\captionformat}{}
\renewcommand*{\figureformat}{}
\renewcommand*{\tableformat}{}
\KOMAoption{captions}{belowfigure,nooneline}
\addtokomafont{caption}{\centering}
\deffootnote[3em]{0em}{4em}{\textsuperscript{\thefootnotemark}~}
\addtokomafont{disposition}{\rmfamily}
\addtokomafont{descriptionlabel}{\rmfamily}
\frenchspacing
% avoid vertical glue
\raggedbottom
% this will generate overfull boxes, so we need to set a tolerance
% \pretolerance=1000
% pretolerance is what is accepted for a paragraph without
% hyphenation, so it makes sense to be strict here and let the user
% accept tweak the tolerance instead.
\tolerance=200
% Additional tolerance for bad paragraphs only
\setlength{\emergencystretch}{30pt}
% (try to) forbid widows/orphans
\clubpenalty=10000
\widowpenalty=10000
% given that we said footinclude=false, this should be safe
\setlength{\footskip}{2\baselineskip}
\title{Upgrading}
\date{}
\author{Marco Pessotto}
\subtitle{}
% https://groups.google.com/d/topic/comp.text.tex/6fYmcVMbSbQ/discussion
\hypersetup{%
pdfencoding=auto,
pdftitle={Upgrading},%
pdfauthor={Marco Pessotto},%
pdfsubject={},%
pdfkeywords={doc; howto}%
}
\begin{document}
\begin{titlepage}
\strut\vskip 2em
\begin{center}
{\usekomafont{title}{\huge Upgrading\par}}%
\vskip 1em
\vskip 2em
{\usekomafont{author}{Marco Pessotto\par}}%
\vskip 1.5em
\vfill
\strut\par
\end{center}
\end{titlepage}
\cleardoublepage
\tableofcontents
% start a new right-handed page
\cleardoublepage
The upgrade procedure depends on the way you installed amusewiki.
\section{Debian package}
The recommended way is to install the application from the debian
packages. That way the upgrade is automatically managed by the
package, with zero downtime.
Please note that if you are using mysql or postgresql, and the
database is currently being restarted by the upgrade procedure, you
will get a failure during the amusewiki upgrade. This is nothing to be
scared. Just run \texttt{apt-get upgrade} again and it will be fixed (again,
without the application going down).
\section{Running in tree with the init script}
If you installed from git and are running the app in the tree:
\begin{alltt}
./init-all.sh stop
git pull
./init-all.sh start
\end{alltt}
DB upgrades are managed automatically. If some manual operation is
required, it will be listed in the Changes file.
This is the suggested script to do a 0-downtime upgrade. We don't ship
it in the distribution because it looks fragile to run a shell script
which potentially could change itself.
\begin{alltt}
\#!/bin/sh
set -e
./script/amusewikifarm\_fastcgi.pl -l var/amw.sock -n 3 2>/dev/null >/dev/null \&
temp\_pid=\$!
echo "Started copy of the application with pid \$temp\_pid. If this script exits prematurely, please kill it yourself"
echo "Waiting for the backup app to come up"
sleep 20
echo "Stopping the app"
./init-all.sh stop
git pull
echo "Starting the app"
./init-all.sh start
echo "Waiting for the new app to come up"
sleep 20
\# kill the old
echo "Stopping the backup app \$temp\_pid"
kill \$temp\_pid
echo "All done, no errors"
\end{alltt}
\section{Running in tree, but started with systemd and selinux}
You could install this script and use it to perform the upgrades (or
do manually with the same logic). Run it as root.
\begin{alltt}
\#!/bin/sh
set -e
amusewiki=/var/www/amusewiki/amusewiki
if [ "x\$1" != "x" ]; then
amusewiki=\$1
fi
if [ -f "\$amusewiki/lib/AmuseWikiFarm.pm" ]; then
owner=`ls -ld "\$amusewiki/lib/AmuseWikiFarm.pm" \textbar{} awk '\{print \$3\}'`;
else
echo "\$amusewiki is not a directory"
exit 2
fi
if [ "\$owner" = "root" ]; then
echo "Owner of amusewiki shouldn't be root";
exit 2;
fi
if [ "x\$owner" = "x" ]; then
echo "Amusewiki owner not found!"
exit 2
fi
if id \$owner > /dev/null; then
echo "Upgrading \$amusewiki owned by \$owner"
sleep 2
else
echo "\$owner not found"
exit 2
fi
systemctl stop amusewiki-jobber
su -c "cd \$amusewiki; git pull; ./init-all.sh start-app" -l \$owner
sleep 10;
systemctl restart amusewiki-web
sleep 10;
su -c "cd \$amusewiki; ./init-all.sh stop-app" -l \$owner
sleep 10;
systemctl start amusewiki-jobber
systemctl restart amusewiki-cgit
sleep 10;
\# check if everything is fine
systemctl status 'amusewiki-*'
ps -u \$owner f
\end{alltt}
% begin final page
\clearpage
% new page for the colophon
\thispagestyle{empty}
\begin{center}
\bigskip
\includegraphics[width=0.25\textwidth]{logo-amw.pdf}
\bigskip
\end{center}
\strut
\vfill
\begin{center}
Marco Pessotto
Upgrading
\bigskip
\bigskip
\textbf{amusewiki.org}
\end{center}
% end final page with colophon
\end{document}
% No format ID passed.