README.md 2.91 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Linkresolver

The linkresolver is a Ruby on Rails application based on the open source umlaut gem.
https://github.com/team-umlaut/umlaut/wiki

## Development environment
The umlaut gem requires Ruby 2.2 and Rails 4.2.5.
It doesn't seem to work with a newer version of Ruby but Ruby 2.2 is no longer supported in modern linux distributions.
For developing and testing the linkresolver there is docker container setup.

### Docker containers

Requirements: recent versions of docker and docker-composer installed.

The development environment consists of 2 containes, one container for the linkresolver (web)
and an other container for the mysql database (db). The web container is defined in de Dockerfile.
The db container uses a standard mysql container. The docker-compose.yml file is used to
start both containers.

Start the development environment with:

        $ docker-compose up

This command starts both containers. The first time it is called it will also build the containers.
If a new web container is needed, which is only neccesary if the content of the Gemfile or start-linkresolver script
has changed, it can be build with this commando:

        $ docker-compose up --build

There is no need to build a new web container when de ruby code has changed because the ruby code is accessed
by the web container through a filesystem mount. Changes in the ruby code are directly active in the linkresolver.
But be aware that the linkresolver stores/caches all requests in the mysql db. So when you change the code and
request the same url again you probably won't see the new behaviour. In that case you have to 'restart' the
containers to 'empty' the database.

To stop the containers use (in a second console):

        $ docker-compose down

Before you can use the development environment to test the code you have to provide the secret keys (environment variables) for the OCLC and BX services in the docker-linkresolver.env file.

        WS_KEY=<oclc secret key>
        BX_TOKEN=<bx secret key>

Be aware: do **NOT** commit the secret keys in the repository!!

You can query the development environment in your browser with an url like this:

        http://localhost:3000/resolve?<open-url>

The log output is written to stdout en to the log files in the log/ directory.

## Deployment

The linkresolver is run on the test (scomp1143) and production (scomp1121) servers in the passenger application server.
The client requests are proxied by apache to the linkresolver instance.

Commands when deploying a new version of the linkresolver on a server (as root):

        # cd /srv/git/library/linkresolver_master/
        # sudo -u linkresolver git pull
        # restart-linkresolver

Above commands are for the test server (scomp1143). For production the linkresolver code is located in /srv/git/library/linkresolver_prod/.

To empty the database, which can be usefull to remove incorrect (cached) responses use the command:

        # clear-linkresolver-db