mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 16:56:56 +00:00
Error Handling in Production mode - Add instructions to README for how to put API in production mode. #268
This commit is contained in:
parent
ec66024d3e
commit
d574428676
145
README.md
145
README.md
@ -34,7 +34,7 @@ The project uses Maven 3 as its build tool.
|
||||
|
||||
To compile and run jetty, install Maven 3 and execute:
|
||||
|
||||
./mvn.sh jetty:run
|
||||
./mvn.sh jetty:run
|
||||
|
||||
## To run with IntelliJ IDEA
|
||||
|
||||
@ -91,13 +91,12 @@ To compile and run jetty, install Maven 3 and execute:
|
||||
## From the command line
|
||||
|
||||
Set memory options
|
||||
export MAVEN_OPTS="-Xmx3000m -XX:MaxPermSize=512m"
|
||||
|
||||
export MAVEN_OPTS="-Xmx3000m -XX:MaxPermSize=512m"
|
||||
|
||||
Run one test
|
||||
mvn -DwildcardSuites=code.api.directloginTest test
|
||||
|
||||
|
||||
----
|
||||
mvn -DwildcardSuites=code.api.directloginTest test
|
||||
|
||||
## Ubuntu
|
||||
|
||||
@ -139,26 +138,26 @@ If Kafka connector is selected in props (connector=kafka), Kafka and Zookeeper h
|
||||
|
||||
* Create file /etc/nginx/sites-available/api
|
||||
|
||||
* Configure as follows
|
||||
* Configure as follows:
|
||||
|
||||
upstream backend {
|
||||
least_conn;
|
||||
server host1:8080; # The name of the server shall be changed as appropriate
|
||||
server host2:8080;
|
||||
server host3:8080;
|
||||
}
|
||||
upstream backend {
|
||||
least_conn;
|
||||
server host1:8080; # The name of the server shall be changed as appropriate
|
||||
server host2:8080;
|
||||
server host3:8080;
|
||||
}
|
||||
|
||||
server {
|
||||
server_name obptest.com www.obptest.com; # The server name should be changed as appropriate
|
||||
access_log /var/log/nginx/api.access.log;
|
||||
error_log /var/log/nginx/api.error.log;
|
||||
location / {
|
||||
proxy_pass http://backend/;
|
||||
}
|
||||
location /obp/v2.1.0/sandbox/data-import {
|
||||
proxy_pass http://backend/;
|
||||
}
|
||||
}
|
||||
server {
|
||||
server_name obptest.com www.obptest.com; # The server name should be changed as appropriate
|
||||
access_log /var/log/nginx/api.access.log;
|
||||
error_log /var/log/nginx/api.error.log;
|
||||
location / {
|
||||
proxy_pass http://backend/;
|
||||
}
|
||||
location /obp/v2.1.0/sandbox/data-import {
|
||||
proxy_pass http://backend/;
|
||||
}
|
||||
}
|
||||
|
||||
2) Zookeeper/Kafka Cluster Setup
|
||||
|
||||
@ -166,79 +165,78 @@ If Kafka connector is selected in props (connector=kafka), Kafka and Zookeeper h
|
||||
|
||||
* Zookeeper configuration
|
||||
|
||||
* Inside the Kafka directory, edit the file conf/zookeeper.properties and include these lines
|
||||
* Inside the Kafka directory, edit the file conf/zookeeper.properties and include these lines:
|
||||
|
||||
dataDir=/home/user/zookeeper
|
||||
dataDir=/home/user/zookeeper
|
||||
server.1=host1:2888:3888 # The name of the servers shall be changed as appropriate
|
||||
server.2=host2:2888:3888
|
||||
server.3=host3:2888:3888
|
||||
initLimit=5
|
||||
syncLimit=2
|
||||
|
||||
server.1=host1:2888:3888 # The name of the servers shall be changed as appropriate
|
||||
server.2=host2:2888:3888
|
||||
server.3=host3:2888:3888
|
||||
initLimit=5
|
||||
syncLimit=2
|
||||
* Create a myid file under dataDir which is /home/user/zookeeper in this example:
|
||||
|
||||
* Create a myid file under dataDir which is /home/user/zookeeper in this example
|
||||
|
||||
echo “1” > /home/user/zookeeper/myid #Insert unique id’s on each of the machines
|
||||
echo “1” > /home/user/zookeeper/myid #Insert unique id’s on each of the machines
|
||||
|
||||
* Start the zookpeer daemons on each of the 3 machines
|
||||
|
||||
bin/zookeeper-server-start.sh config/zookeeper.properties &
|
||||
bin/zookeeper-server-start.sh config/zookeeper.properties &
|
||||
|
||||
* Kafka Configuration
|
||||
|
||||
* Inside the Kafka directory, edit the file conf/server.properties and include these lines
|
||||
* Inside the Kafka directory, edit the file conf/server.properties and include these lines:
|
||||
|
||||
broker.id=1 # The broker.id should be unique for each host
|
||||
broker.id=1 # The broker.id should be unique for each host
|
||||
|
||||
num.partitions=4
|
||||
num.partitions=4
|
||||
|
||||
zookeeper.connect=host1:2181,host2:2181,host3:2181
|
||||
zookeeper.connect=host1:2181,host2:2181,host3:2181
|
||||
|
||||
* Start the kafka broker daemons on all the machines
|
||||
* Start the kafka broker daemons on all the machines:
|
||||
|
||||
bin/kafka-server-start.sh config/server.properties &
|
||||
bin/kafka-server-start.sh config/server.properties &
|
||||
|
||||
* Create the topics
|
||||
* Create the topics:
|
||||
|
||||
bin/kafka-topics.sh --create --zookeeper host1:2181,host2:2181,host3:2181 --replication-factor 1 --partitions 1 --topic Request
|
||||
bin/kafka-topics.sh --create --zookeeper host1:2181,host2:2181,host3:2181 --replication-factor 1 --partitions 1 --topic Request
|
||||
|
||||
bin/kafka-topics.sh --create --zookeeper host1:2181,host2:2181,host3:2181 --replication-factor 1 --partitions 1 --topic Response
|
||||
bin/kafka-topics.sh --create --zookeeper host1:2181,host2:2181,host3:2181 --replication-factor 1 --partitions 1 --topic Response
|
||||
|
||||
3) OBP-API
|
||||
|
||||
* Configuration
|
||||
|
||||
* Edit the OBP-API/src/main/resources/props/default.props so that it contains the following lines. This should be done on each node.
|
||||
* Edit the OBP-API/src/main/resources/props/default.props so that it contains the following lines. This should be done on each node:
|
||||
|
||||
connector=kafka
|
||||
kafka.zookeeper_host=localhost:2181
|
||||
kafka.request_topic=Request
|
||||
kafka.response_topic=Response
|
||||
connector=kafka
|
||||
kafka.zookeeper_host=localhost:2181
|
||||
kafka.request_topic=Request
|
||||
kafka.response_topic=Response
|
||||
|
||||
* Start the server
|
||||
* Start the server:
|
||||
|
||||
cd OBP-API
|
||||
mvn jetty:run
|
||||
cd OBP-API
|
||||
mvn jetty:run
|
||||
|
||||
4) OBP-JVM
|
||||
|
||||
* Build the package
|
||||
* Build the package:
|
||||
|
||||
cd OBP-JVM
|
||||
mvn install
|
||||
cd OBP-JVM
|
||||
mvn install
|
||||
|
||||
* Run the demo
|
||||
* Run the demo:
|
||||
|
||||
java -jar obp-ri-demo/target/obp-ri-demo-2016.9-SNAPSHOT-jar-with-dependencies.jar&
|
||||
java -jar obp-ri-demo/target/obp-ri-demo-2016.9-SNAPSHOT-jar-with-dependencies.jar&
|
||||
|
||||
* Here be aware that the name of the jar file might be different, so make sure to use the correct name of the jar file
|
||||
|
||||
5) OBP-Kafka-Python
|
||||
|
||||
* Run from the command line
|
||||
* Run from the command line:
|
||||
|
||||
cd OBP-Kafka-Python
|
||||
python server.py
|
||||
cd OBP-Kafka-Python
|
||||
python server.py
|
||||
|
||||
6) To test the setup, try a request
|
||||
|
||||
@ -246,8 +244,7 @@ http://localhost:8080/obp/v2.0.0/banks
|
||||
|
||||
# Production Options.
|
||||
|
||||
* set the status of HttpOnly and Secure cookie flags for produnction
|
||||
,uncomment the following lines of "webapp/WEB-INF/web.xml" :
|
||||
* set the status of HttpOnly and Secure cookie flags for produnction,uncomment the following lines of "webapp/WEB-INF/web.xml" :
|
||||
|
||||
<session-config>
|
||||
<cookie-config>
|
||||
@ -266,9 +263,9 @@ We use jetty8 to run the API in production mode.
|
||||
|
||||
* Edit the /etc/default/jetty8 file so that it contains the following settings:
|
||||
|
||||
NO_START=0
|
||||
JETTY_HOST=127.0.0.1 (If you want your application to be accessed from other hosts, change this to your IP address)
|
||||
JAVA_OPTIONS="-Drun.mode=production -XX:PermSize=256M -XX:MaxPermSize=512M -Xmx768m -verbose -Dobp.resource.dir=$JETTY_HOME/resources -Dprops.resource.dir=$JETTY_HOME/resources"
|
||||
NO_START=0
|
||||
JETTY_HOST=127.0.0.1 #If you want your application to be accessed from other hosts, change this to your IP address
|
||||
JAVA_OPTIONS="-Drun.mode=production -XX:PermSize=256M -XX:MaxPermSize=512M -Xmx768m -verbose -Dobp.resource.dir=$JETTY_HOME/resources -Dprops.resource.dir=$JETTY_HOME/resources"
|
||||
|
||||
* In src/main/resources/props create a test.default.props file for tests. Set connector=mapped
|
||||
|
||||
@ -278,26 +275,26 @@ We use jetty8 to run the API in production mode.
|
||||
|
||||
* This file could be similar to the default.props file created above, or it could include production settings, such as information about Postgresql server, if you are using one. For example, it could have the following line for postgresql configuration.
|
||||
|
||||
db.driver=org.postgresql.Driver
|
||||
db.url=jdbc:postgresql://localhost:5432/dbname?user=yourdbusername&password=yourpassword
|
||||
db.driver=org.postgresql.Driver
|
||||
db.url=jdbc:postgresql://localhost:5432/yourdbname?user=yourdbusername&password=yourpassword
|
||||
|
||||
* Now, build the application to generate .war file which will be deployed on jetty8 server.
|
||||
* Now, build the application to generate .war file which will be deployed on jetty8 server:
|
||||
|
||||
cd OBP-API/
|
||||
mvn package
|
||||
cd OBP-API/
|
||||
mvn package
|
||||
|
||||
* This will generate OBP-API-1.0.war under OBP-API/target/
|
||||
|
||||
* Copy OBP-API-1.0.war to /usr/share/jetty8/webapps/ directory and rename it to root.war
|
||||
|
||||
* Edit the /etc/jetty8/jetty.conf file and comment out the lines
|
||||
* Edit the /etc/jetty8/jetty.conf file and comment out the lines:
|
||||
|
||||
#etc/jetty-logging.xml
|
||||
#etc/jetty-started.xml
|
||||
etc/jetty-logging.xml
|
||||
etc/jetty-started.xml
|
||||
|
||||
* Now restart jetty8
|
||||
* Now restart jetty8:
|
||||
|
||||
sudo service jetty8 restart
|
||||
sudo service jetty8 restart
|
||||
|
||||
* You should now be able to browse to localhost:8080 (or yourIPaddress:8080)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user