Kallithea Deployment Release 0.0
Total Page:16
File Type:pdf, Size:1020Kb
Kallithea Deployment Release 0.0 Wolfgang Scherer Jan 10, 2020 Quickstart Local: • Deployment documentation: Kallithea deployment documentation • Deployment repository: Kallithea deployment repository • Installed instance: Kallithea installed instance Official: • Web-Site: Kallithea • Documentation: Kallithea Documentation • Repository: https://kallithea-scm.org/repos/kallithea • Bitbucket: conservancy / kallithea - Bitbucket (as long as it still works) Abstract CONTENTS List of Figures ii List of Tables iii List of Code Blocks iv 1 Installation 1 1.1 Get deployment package.......................................1 1.2 System packages...........................................1 1.3 Installation / update.........................................1 1.4 Initial setup..............................................2 1.5 Initialize repository defaults.....................................2 1.6 Setup repos/incoming........................................3 1.7 Create clone script..........................................3 1.8 Full text search............................................3 1.9 Install a language file for en .....................................3 2 Update 5 2.1 Database update...........................................5 3 Serve with gearbox 6 4 npm on Debian 7 5 Apache configuration 8 6 Kallithea deployment 10 6.1 Repositories............................................. 10 6.2 Documentation............................................ 10 7 LDAP 11 8 Bug: Logging re-initialized in make_app() 12 8.1 Paste Deploy WSGI app configuration................................ 12 8.2 Paste Script logging......................................... 13 8.3 Gearbox............................................... 15 8.4 Pyramid................................................ 17 8.5 kallithea-cli.............................................. 19 8.6 Kallithea details........................................... 19 9 Accept-Language bug 21 9.1 Solution with i18n.notrans patch................................... 21 10 Patch needed for Python 2.7.3 24 i LIST OF FIGURES 8.1 loadapp call chain........................................... 13 ii LIST OF TABLES iii LIST OF CODE BLOCKS iv CHAPTER ONE INSTALLATION See Installation on Unix/Linux On Debian, NPM must be installed (see section4, npm on Debian). 1.1 Get deployment package cd" ${HOME}/project" mkdir -p kallithea cd kallithea isy -n Edit .sync.defs to reflect correct info: @RUSER sw @RHOST scherer.wiedenmann.intern @SCP_REMOTE /home/sw/project/kallithea Get package: ./sync.sh --restore 1.2 System packages sudo apt-get install --yes build-essential git python-pip python-virtualenv libffi-dev python- ,!dev nodejs test -r /usr/bin/node || sudo ln -s nodejs /usr/bin/node; node --version test -r /usr/bin/npm || sudo apt-get install --yes npm # Ubuntu 18.04 Up to date packages for mercurial and tortoisehg are on sw-amt.ws. apt-get install --yes tortoisehg 1.3 Installation / update cd" ${HOME}/project" mkdir -p kallithea cd kallithea test -d kallithea || \ hg clone https://kallithea-scm.org/repos/kallithea -u stable cd kallithea (continues on next page) 1 Kallithea Deployment, Release 0.0 (continued from previous page) test -d ../kallithea-venv || \ ( virtualenv ../kallithea-venv ../kallithea-venv/bin/pip install --upgrade pip setuptools ) . ../kallithea-venv/bin/activate pip install --upgrade -e . python2 setup.py compile_catalog # for translation of the UI 1.4 Initial setup cd" ${HOME}/project" cd kallithea/kallithea mkdir -p ../log Move existing repositories away until the repository defaults (activated statistics and download) are set: ( cd" ${HOME}"/project/kallithea || exit1; \ test ! -d repos ||( mv repos repos-000); \ mkdir -p repos) Create new configuration and update it from an existing one: kallithea-cli config-create cfg-HOSTNAME.ini host=0.0.0.0 port=5020 # update configuration with e.g.: diff -u cfg-sw-amt.ini cfg-HOSTNAME.ini (beware the ,!absolute path names in log handler sections) # (ediff-files "~/project/kallithea/kallithea/cfg-sw-amt.ini" "~/project/kallithea/kallithea/ ,!cfg-HOSTNAME.ini") Generate development and wsgi configurations: ../config_admin.sh link HOSTNAME This installs links to created configurations: Link Configuration config.ini cfg-HOSTNAME.ini config-dev.ini cfg-HOSTNAME-dev.ini config-wsgi.ini cfg-HOSTNAME-wsgi.ini Create new database: kallithea-cli db-create -c config.ini --user=admin --password=ktBE216 --email=edv@ws-gruppe. ,!de --repos="${HOME}"/project/kallithea/repos Build frontend: kallithea-cli front-end-build 1.5 Initialize repository defaults Either serve with gearbox (see section3, Serve with gearbox) or complete Apache configuration (see section5, Apache configuration), then login as admin and activate downloads and statistics for new repositories und Admin - Repositorystandards. 2 Chapter 1. Installation Kallithea Deployment, Release 0.0 Restore existing repository tree: ( cd" ${HOME}"/project/kallithea || exit1; \ test ! -d repos-000 ||( rmdir repos&& mv repos-000 repos)) Clone repositories: cd" ${HOME}"/project/kallithea cp ./clone_repos_sw_scherer.sh ../clone_repo.sh chmod +x ../clone_repo.sh cd.. ./clone_repo.sh Rescan repositories under Admin - Settings - Remap and Rescan, or run: cd" ${HOME}"/project/kallithea/kallithea kallithea-cli repo-scan --config_file config.ini --remove-missing 1.6 Setup repos/incoming Create this as repository group without group access! cd" ${HOME}"/project/kallithea mkdir -p repos/incoming cd repos/incoming ln -s ../../link_repos.sh . 1.7 Create clone script cd" ${HOME}"/project/kallithea/repos/incoming ./link_repos.sh --active >../../clone_repos.sh 1.8 Full text search "${HOME}"/project/kallithea/kallithea-venv/bin/kallithea-cli index-create -c" ${HOME}"/ ,!project/kallithea/kallithea/config.ini --full 'all' /etc/cron.d/local-kallithea: 0 3 *** @user@ test ! -x /home/@user@/project/kallithea/kallithea-venv/bin/kallithea- ,!cli || /home/@user@/project/kallithea/kallithea-venv/bin/kallithea-cli index-create -c / ,!home/@user@/project/kallithea/kallithea/config.ini 1.9 Install a language file for en Having an explcit translation file for English en avoids the bug, where the language en is not used for an Accept-Language header of, e.g., en-US, en;q=0.8, de-DE;q=0.5, de;q=0.3 (see section9, Accept-Language bug). As pointed out by kiilerix in comment of option i18n.notrans for language alias of C locale, the language file can be empty, if option i18n.lang is set: 1.6. Setup repos/incoming 3 Kallithea Deployment, Release 0.0 i18n.lang= en If kallithea does not provide it, the translation file can be generated with: cd ~/project/kallithea . ./activate cd kallithea if test ! -r kallithea/i18n/en/LC_MESSAGES/kallithea.po&& test ! -r kallithea/i18n/en/LC_ ,!MESSAGES/kallithea.mo then python2 setup.py extract_messages # create kallithea/i18n/kallithea.pot python2 setup.py init_catalog -l en # create kallithea/i18n/en/LC_MESSAGES/kallithea.po python2 setup.py compile_catalog -l en # # create kallithea/i18n/en/LC_MESSAGES/kallithea. ,!mo rm -f kallithea/i18n/en/LC_MESSAGES/kallithea.po # clean up, for when .po is distributed ,!by a newer version of Kallithea fi It is also possible to create the empty translation file manually (not recommended) with: mkdir -p kallithea/i18n/en/LC_MESSAGES printf '\x95\x04\x12\xde\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0' > kallithea/i18n/en/LC_MESSAGES/ ,!kallithea.mo 4 Chapter 1. Installation CHAPTER TWO UPDATE See Upgrading Kallithea - Kallithea 0.5.0 documentation 2.1 Database update cd kallithea alembic -c development.ini upgrade head 5 CHAPTER THREE SERVE WITH GEARBOX ." ${HOME}"/project/kallithea/kallithea-venv/bin/activate gearbox serve -c config-dev.ini 6 CHAPTER FOUR NPM ON DEBIAN Needs npm on Debian (https://nodejs.org/fa/download/package-manager/): wget -qO- https://deb.nodesource.com/setup_6.x | sudo -E bash - apt-get install --yes nodejs 7 CHAPTER FIVE APACHE CONFIGURATION apt-get install --yes apache2 libapache2-mod-wsgi Enable system locale in /etc/apache2/envvars (remove # from . /etc/default/locale). /etc/apache2/conf-available/wsgi-kallithea.conf (replace @user@ with correct user): #-*- mode: conf; tab-width: 4; -*- # WSGI script WSGIDaemonProcess kallithea user=@user@ group=@user@ processes=5 threads=1 \ python-path=/home/@user@/project/kallithea/kallithea-venv/lib/python2.7/site-packages:/ ,!home/@user@/project/kallithea/kallithea-venv/lib/python2.7 # lang=de_DE.UTTF-8 WSGIScriptAlias /kallithea /home/@user@/project/kallithea/kallithea-dispatch.wsgi # |:sec:| kallithea <Directory /home/@user@/project/kallithea> RewriteEngine on RewriteCond %{REQUEST_URI} /kallithea$ [NC] RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,NC,L] # Use only 1 Python sub-interpreter. Multiple sub-interpreters # play badly with C extensions. WSGIApplicationGroup %{GLOBAL} WSGIPassAuthorization On WSGIProcessGroup kallithea AllowOverride All <IfVersion < 2.3 > Order allow,deny Allow from all </IfVersion> <IfVersion !< 2.3> Require all granted </IfVersion> # # <IfModule mod_authn_sasl.c> # AuthType Basic # AuthName "kallithea" # AuthBasicProvider sasl # # AuthBasicProvider file sasl # AuthBasicAuthoritative On # AuthSaslPwcheckMethod saslauthd # # AuthUserFile /home/@user@/project/kallithea/data/.htpasswd # Require valid-user # # </IfModule> </Directory> # :ide: CMD: restart apache # . (let* ((fp (buffer-file-name)) (fn (file-name-nondirectory fp))) (shell-command (concat "/ ,!etc/init.d/apache2 restart" ) nil nil)) # :ide: CMD: reload apache # . (let* ((fp (buffer-file-name)) (fn (file-name-nondirectory fp))) (shell-command (concat "/