Skip to content

Latest commit

 

History

History
363 lines (230 loc) · 9.9 KB

INSTALL.rst

File metadata and controls

363 lines (230 loc) · 9.9 KB

Native Install (CentOS - MacOS)

System prerequisites

This guide expects you to have installed in your system the following tools:

  • git
  • virtualenv
  • virtualenvwrapper
  • npm > 3.0
  • postgresql + devel headers
  • libxml2 + devel headers
  • libxslt + devel headers
  • ImageMagick
  • redis
  • elasticsearch

CentOS

$ sudo yum install python-virtualenv python-virtualenvwrapper \
    npm postgresql postgresql-devel libxml2-devel ImageMagick redis git \
    libxslt-devel
$ sudo npm -g install npm

For elasticsearch you can find the installation instructions on the elasticsearch install page, and, to run the development environment, you will need also to add the following workarounds:

$ sudo usermod -a -G $USER elasticsearch
$ newgrp elasticsearch  # or log out and in again
$ sudo ln -s /etc/elasticsearch /usr/share/elasticsearch/config

MacOS

$ brew install postgresql
$ brew install libxml2
$ brew install libxslt
$ brew install redis
$ brew cask install caskroom/versions/java8
$ brew install [email protected]
$ brew install rabbitmq
$ brew install imagemagick@6
$ brew install libmagic
$ brew install ghostscript
$ brew install poppler

You might also need to link imagemagick:

$ brew link --force imagemagick@6

Add to ~/.bash_profile:

# ElasticSearch.
export PATH="/usr/local/opt/[email protected]/bin:$PATH"

Create a virtual environment

Create a virtual environment and clone the INSPIRE source code using git:

$ mkvirtualenv --python=python2.7 inspirehep
$ workon inspirehep
(inspirehep)$ cdvirtualenv
(inspirehep)$ mkdir src
(inspirehep)$ git clone https://github.com/inspirehep/inspire-next.git src/inspirehep

Note

It is also possible (and more flexible) to do the above the other way around like this and clone the project into a folder of your choice:

$ git clone https://github.com/inspirehep/inspire-next.git inspirehep
$ cd inspirehep
$ mkvirtualenv --python=python2.7 inspirehep
$ workon inspirehep

This approach enables you to switch to a new virtual environment without having to clone the project again. You simply specify on which environment you want to workon using its name.

Just be careful to replace all cdvirtualenv src/inspirehep in the following with a cd path_you_chose/inspirehep.

Install requirements

Use pip to install all requirements, it's recommended to upgrade pip and setuptools to latest too:

(inspirehep)$ pip install --upgrade pip setuptools
(inspirehep)$ cdvirtualenv src/inspirehep
(inspirehep)$ pip install -r requirements.txt --pre --exists-action i
(inspirehep)$ pip install honcho

And for development:

(inspirehep)$ pip install -e .[development]

Custom configuration and debug mode

If you want to change the database url, or enable the debug mode for troubleshooting, you can do so in the inspirehep.cfg file under var/inspirehep-instance, you might need to create it:

(inspirehep)$ cdvirtualenv var/inspirehep-instance
(inspirehep)$ vim inspirehep.cfg

There you can change the value of any of the variables that are set under the file src/inspirehep/inspirehep/config.py, for example:

DEBUG = True
SQLALCHEMY_DATABASE_URI = "postgresql+psycopg2://someuser:[email protected]:5432/inspirehep"

Note

Make sure that the configuration keys you override here have the same exact name as the ones in the config.py file, as it will not complain if you put a key that did not exist.

Build assets

We build assets using npm. Make sure you have installed it system wide.

(inspirehep)$ sudo npm update
(inspirehep)$ sudo npm install -g [email protected] clean-css@^3.4.24 requirejs uglify-js

Note

If you don't want to use sudo to install the npm packages globally, you can still setup a per-user npm modules installation that will allow you to install/remove modules as normal user. You can find more info in the npm docs here.

In particular, if you want to install the npm packages directly in your virtualenv, just add NPM_CONFIG_PREFIX=$VIRTUAL_ENV in the postactivate file of your virtualenv folder and you will be able to run the above command from inside your virtual environment.

Then we build the INSPIRE assets:

(inspirehep)$ inspirehep npm
(inspirehep)$ cdvirtualenv var/inspirehep-instance/static
(inspirehep)$ npm install
(inspirehep)$ inspirehep collect -v
(inspirehep)$ inspirehep assets build

Note

Alternatively, run sh scripts/clean_assets to do the above in one command.

Create database

We will use postgreSQL as database. Make sure you have installed it system wide.

Then create the database and database tables if you haven't already done so:

(inspirehep)$ psql
# CREATE USER inspirehep WITH PASSWORD 'dbpass123';
# CREATE DATABASE inspirehep;
# GRANT ALL PRIVILEGES ON DATABASE inspirehep to inspirehep;
(inspirehep)$ inspirehep db init
(inspirehep)$ inspirehep db create

Start all services

Rabbitmq

You must have rabbitmq installed and running (and reachable) somewhere. To run it locally on a CentOS:

$ sudo yum install rabbitmq-server
$ sudo service rabbitmq-server start
$ sudo systemctl enable rabbitmq-server.service  # to start on system boot

Everything else: Honcho

We use honcho to manage our services and run the development server. See Procfile for details.

(inspirehep)$ cdvirtualenv src/inspirehep
(inspirehep)$ honcho start

In MacOS you still need to manually run rabbitmq and postgresql:

$ brew services start rabbitmq
$ brew services start postgresql

And the site is now available on http://localhost:5000.

Create ElasticSearch Indices and Aliases

Note

Remember that you'll need to have the elasticsearch bin directory in your $PATH or prepend the binaries executed with the path to the elasticsearch bin directory in your system.

First of all, we will need to install the analysis-icu elasticsearch plugin.

(inspirehep)$ plugin install analysis-icu

For MacOS the plugin command will probably not be available system wide, so:

$ /usr/local/Cellar/elasticsearch\@2.4/2.4.6/libexec/bin/plugin install analysis-icu

Now we are ready to create the indexes:

(inspirehep)$ inspirehep index init

If you are having troubles creating your indices, e.g. due to index name changes or existing legacy indices, try:

(inspirehep)$ inspirehep index destroy --force --yes-i-know
(inspirehep)$ inspirehep index init

Create admin user

Now you can create a sample admin user, for that we will use the fixtures:

(inspirehep)$ inspirehep fixtures init

Note

If you are not running in debug mode, remember to add the local=1 HTTP GET parameter to the login url so it will show you the login form, for example:

http://localhost:5000/login/?local=1

Add demo records

(inspirehep)$ cdvirtualenv src/inspirehep
(inspirehep)$ inspirehep migrate file --force --wait inspirehep/demosite/data/demo-records.xml.gz

Note

Alternatively, run sh scripts/recreate_records to drop db/index/records and re-create them in one command, it will also create the admin user.

Warning

Remember to keep honcho running in a separate window.

Create regular user

Now you can create regular users (optional) with the command:

(inspirehep)$ inspirehep users create [email protected] -a

Access the records (web/rest)

While running honcho you can access the records at

$ firefox http://localhost:5000/literature/1
$ curl -i -H "Accept: application/json" http://localhost:5000/api/records/1