Skip to content

Commit bfd7e55

Browse files
Docs: Improve Aerospike-related docs (#122)
1 parent b781faf commit bfd7e55

File tree

1 file changed

+72
-37
lines changed

1 file changed

+72
-37
lines changed

README.md

Lines changed: 72 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Project configuration is managed through the use of YAML configuration (see reso
99
### _Requirements_
1010
This section covers the mandatory pre-requisites needed to be able to run the application.
1111

12-
* Windows, Linux, AWS, GCP or MacOS
12+
* Windows, Linux, AWS, GCP or macOS
1313
* JDK 8+
1414
* Maven
1515
* Git
@@ -19,27 +19,64 @@ This section covers the mandatory pre-requisites needed to be able to run the ap
1919
### _Quick Install_
2020
This section describes how to download, install and run the application.
2121

22-
###### A. Using Maven on MacOS (recommended installation method)
22+
###### A. Using Maven on macOS (recommended installation method)
2323

2424
(1). Clone the repo:
2525

2626
```bash
27-
$ git clone https://github.com/prebid/prebid-cache-java.git
27+
git clone https://github.com/prebid/prebid-cache-java.git
2828
```
2929

3030
(2). Start Redis or Aerospike:
31+
If you have installed [Redis](https://redis.io/docs/install/install-redis/) or [Aerospike](https://aerospike.com/docs/server/operations/install) locally, you may start them both (or separately, depends on your needs) via bash:
32+
```bash
33+
sudo systemctl start redis
34+
sudo systemctl start aerospike
35+
```
36+
Alternatively, you may start DB as Docker image.
37+
You should install [Docker Engine](https://docs.docker.com/engine/install/) if you don't have one.
3138

39+
(2.1) Redis via Docker
40+
1. Pull [Redis docker image](https://hub.docker.com/_/redis) of an appropriate version
41+
```bash
42+
docker pull redis:<version>
43+
```
44+
2. Run Redis container
45+
- the `<version>` should correspond to the pulled image version
46+
- the `<host_port>` should correspond to the `spring.redis.port` property values of the Prebid Cache
47+
```bash
48+
docker run -d --name redis -p <host_port>:<container_port> redis:<version>
49+
50+
# Example (the host will be defined as localhost by default)
51+
docker run -d --name redis -p 6379:6379 redis:7.2.4
52+
```
53+
54+
(2.2) Aerospike via Docker
55+
1. Pull [Aerospike docker image](https://hub.docker.com/_/aerospike) of an appropriate version
56+
```bash
57+
docker pull aerospike:<version>
58+
```
59+
2. Run Aerospike container (the following instruction is enough for the Community Edition only)
60+
- the `<version>` should correspond to the pulled image version
61+
- the `<host_port>` should correspond to the `spring.aerospike.port` property values of the Prebid Cache
62+
- the `<namespace>` should correspond to the spring.aerospike.namespace property value of the Prebid Cache
3263
```bash
33-
$ nohup redis-server &
64+
docker run -d --name aerospike -e "NAMESPACE=<namespace>" -p <host_port>:<container_port> aerospike:<version>
3465

35-
$ sudo service aerospike start
66+
# Example (the host will be defined as localhost by default)
67+
docker run -d --name aerospike -e "NAMESPACE=prebid_cache" -p 3000:3000 aerospike:ce-6.4.0.2_1
68+
```
69+
70+
(2.3) Make sure that the Aerospike and/or Redis is up and running
71+
```bash
72+
docker ps
3673
```
3774

3875
(3). Start the Maven build
3976

4077
```bash
41-
$ cd prebid-cache-java
42-
$ mvn clean package
78+
cd prebid-cache-java
79+
mvn clean package
4380
...
4481
[INFO] Layout: JAR
4582
[INFO] ------------------------------------------------------------------------
@@ -54,7 +91,7 @@ $ mvn clean package
5491
(4). Run Spring Boot JAR (_from project root_)
5592

5693
```bash
57-
$ java -jar target/prebid-cache.jar
94+
java -jar target/prebid-cache.jar
5895
```
5996

6097
### _Spring Profiles_
@@ -65,14 +102,14 @@ This section shows examples of the various runtime environment configuration(s).
65102

66103
_VM Options:_
67104
```bash
68-
$ java -jar prebid-cache.jar -Dspring.profiles.active=manage,local -Dlog.dir=/app/prebid-cache-java/log/
105+
java -jar prebid-cache.jar -Dspring.profiles.active=manage,local -Dlog.dir=/app/prebid-cache-java/log/
69106
```
70107

71108
(2). Production with log4j and management endpoints disabled:
72109

73110
_VM Options:_
74111
```bash
75-
$ java -jar prebid-cache.jar -Dspring.profiles.active=prod -Dlog.dir=/app/prebid-cache-java/log/
112+
java -jar prebid-cache.jar -Dspring.profiles.active=prod -Dlog.dir=/app/prebid-cache-java/log/
76113
```
77114

78115
### _Cache Configuration_
@@ -159,7 +196,6 @@ A configuration object should be passed into the constructor of your custom repo
159196
this.config = config;
160197
}
161198
}
162-
163199
```
164200

165201
Here is an example definition of a custom configuration property class. It is important to replace _'custom'_ with the correct cache implementation name (e.g. redis, memcached, aerospike, etc...). If Spring already provides a predefined configuration property prefix, please use that instead.
@@ -176,7 +212,6 @@ public class CustomPropertyConfiguration
176212
private String host;
177213
private int port;
178214
}
179-
180215
```
181216

182217
### _Metrics_
@@ -317,29 +352,29 @@ https://github.com/spring-projects/spring-boot/issues/12188
317352

318353
To launch the JAR from the command line (UNIX/Linux):
319354
```bash
320-
$ ./prebid-cache.jar
355+
./prebid-cache.jar
321356
```
322357

323358
For security reasons, it is recommended to run the service as a non-root user:
324359
```bash
325-
$ sudo useradd prebid-cache
326-
$ sudo passwd prebid-cache
327-
$ sudo chown prebid-cache:prebid-cache prebid-cache.jar
328-
$ sudo chmod 500 prebid-cache.jar
360+
sudo useradd prebid-cache
361+
sudo passwd prebid-cache
362+
sudo chown prebid-cache:prebid-cache prebid-cache.jar
363+
sudo chmod 500 prebid-cache.jar
329364
```
330365

331366
###### B. System V Init
332367

333368
Symbolic link JAR to init.d:
334369
```bash
335-
$ sudo ln -s /app/prebid-cache.jar /etc/init.d/prebid-cache
370+
sudo ln -s /app/prebid-cache.jar /etc/init.d/prebid-cache
336371
```
337372

338373
```bash
339-
$ sudo service prebid-cache start # start service
340-
$ sudo service prebid-cache status # check status
341-
$ sudo service prebid-cache stop # stop service
342-
$ sudo service prebid-cache restart # restart service
374+
sudo service prebid-cache start # start service
375+
sudo service prebid-cache status # check status
376+
sudo service prebid-cache stop # stop service
377+
sudo service prebid-cache restart # restart service
343378
```
344379

345380
Following these steps will allow for:
@@ -350,7 +385,7 @@ Following these steps will allow for:
350385
###### C. Systemd
351386

352387
/etc/systemd/system/prebid-cache.service:
353-
```bash
388+
```text
354389
[Unit]
355390
Description=Prebid Cache Service
356391
After=syslog.target
@@ -362,13 +397,12 @@ SuccessExitStatus=143
362397
363398
[Install]
364399
WantedBy=multi-user.target
365-
366400
```
367401
Now you can manage this service with systemctl:
368402
```bash
369-
$ systemctl start prebid-cache.service # start service
370-
$ systemctl stop prebid-cache.service # stop service
371-
$ systemctl status prebid-cache.service # check status
403+
systemctl start prebid-cache.service # start service
404+
systemctl stop prebid-cache.service # stop service
405+
systemctl status prebid-cache.service # check status
372406
```
373407
For more details please refer to man pages for systemctl.
374408

@@ -379,38 +413,39 @@ This section describes how to run the app in an Elastic Beanstalk environment wi
379413

380414
(1). Go to the project root:
381415
```bash
382-
$ cd prebid-cache-java
416+
cd prebid-cache-java
383417
```
384418

385419
(2). Update codebase :
386420
```bash
387-
$ git pull
421+
git pull
388422
```
389423

390424
(3). Rebuild sources with Maven
391425
```bash
392-
$ mvn clean gplus:execute package
426+
mvn clean gplus:execute package
393427
```
394428

395429
(4). Create folder in work directory:
396430
```bash
397-
$ mkdir aws-prebid-cache
431+
mkdir aws-prebid-cache
398432
```
399433

400434
(5). Copy jar file from prebid-cache-java/target to created directory:
401435
```bash
402-
$ cp prebid-cache-java/target/prebid-cache.jar aws-prebid-cache
436+
cp prebid-cache-java/target/prebid-cache.jar aws-prebid-cache
403437
```
404438

405439
(6). Create Procfile in aws-prebid-cache directory:
406440
```bash
407-
$ sudo nano Procfile
441+
sudo nano Procfile
442+
408443
web: java -jar -Dspring.profiles.active=aws prebid-cache.jar
409444
```
410445

411446
(7). Zip aws-prebid-cache directory
412447
```bash
413-
$ zip -r eb-prebid-cache-new.zip eb-prebid-cache-new
448+
zip -r eb-prebid-cache-new.zip eb-prebid-cache-new
414449
```
415450
Artifact is ready for deploy to Elastic Beanstalk.
416451
For more information, see https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-se-platform.html.
@@ -490,17 +525,17 @@ For using the latest version of prebid cache, perform next steps:
490525

491526
(1). Go to the project root:
492527
```bash
493-
$ cd prebid-cache-java
528+
cd prebid-cache-java
494529
```
495530

496531
(2). Update codebase:
497532
```bash
498-
$ git pull
533+
git pull
499534
```
500535

501536
(3). Rebuild sources with Maven
502537
```bash
503-
$ mvn clean gplus:execute package
538+
mvn clean gplus:execute package
504539
```
505540

506541
If there are any questions, issues, or concerns, please submit them to https://github.com/prebid/prebid-cache-java/issues/.

0 commit comments

Comments
 (0)