blob: 79f7d3d79015135d56565ec415343d3b9561f314 [file] [log] [blame]
////
*******************************************************************************
* Copyright (c) 2018 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************
////
= openKonsequenz - How to run the module "Plannedgridmeasures"
:Date: 2018-06-25
:Revision: 1
:icons:
:source-highlighter: highlightjs
:highlightjs-theme: solarized_dark
<<<
IMPORTANT: Please be sure that you have first *Portal (Auth n Auth)* installed and configured!
== Requirements
* Java 8 Runtime Environment
* Build-Artifacts (look at *howtoBuild* or you get them from a Jenkins source as zip):
** MicsHomeService Backend
** MicsCentralService Backend-Microservice
** PlannedGridMeasures Backend-Microservice
** PlannedGridMeasures Frontend
== Prerequisites
* *Portal (Auth n Auth) application has to be installed and configured.* The Portal is the entrypoint
for this module and mandatory for its authentification.
==== Install and Configure Apache Tomcat
Tomcat is an open-source Java Servlet Container and provides a "pure Java" HTTP web server environment in which Java code can run.
1. Download Tomcat version 8.5.24 from https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.24/bin
and extract it (apache-tomcat-8.5.24.zip).
2. Configure Tomcat:
a. Configure the *context.xml* file. Copy the *<Resource >* block from the project file `deploy/conf/`*context.xml*
and paste it in the `<tomcat>/conf/`*context.xml* in the *<Context>* block.
b. Dont forget to save it.
TIP: For more informations check *Deployment View* Chapter in *http://169.50.13.154/gridMeasuresADoc/architectureDocumentation.html[PlannedGridMeasures Architecture Documentation]*.
** Tomcat also needs the database driver to be placed in `<tomcat>/lib`. Find it in the project file `deploy/lib/`*postgresql-xxx.jar*.
TIP: It is recommend to install a service for starting and stopping the Apache Tomcat.
==== Install and Configure a PostgreSQL database
To work with a postgreSQL database pgAdmin is suggested
1. Download and install pgAdmin (we suggest "Version 3" since it performs better than "Version 4") from:
https://www.pgadmin.org/download/
2. Create a database and adapt the `<tomcat>/conf/`*context.xml* file to your database (look at *Install and Configure Apache Tomcat*).
3. To initialize the database schema run the last sql script:
/db/migrations/V0_XX__CREATE_PLGM_DB.sql
TIP: It is recommend to install a service for starting and stopping the PostgreSQL database.
TIP: For detailed instructions look at *http://169.50.13.154/gridMeasuresADoc/architectureDocumentation.html[PlannedGridMeasures Architecture Documentation]*.
== How to deploy and run the Backend
To run the backend you need to have installed and configured Apache Tomcat (look at *Install and Configure Apache Tomcat*).
The Backend consists of 3 Artifacts:
** One Web Application Archive (war) file which is deployed on an Apache Tomcat
*** MicsHomeService (*mics-home-service.war*)
** Two Java Archives (jar) started as Microservices
*** MicsCentralService Backend-Microservice (*mics-central-service.jar*)
*** PlannedGridMeasures Backend-Microservice (*planned-grid-measures.jar*)
=== Deploy MicsHomeService (war-file) and start Apache Tomcat
Tomcat needs the Web Application Archive (war) file. Get it from a successfully maven build or via zip from a Jenkins source.
1. Copy the *mics-home-service.war* file from the `/target` folder of
project "MicsHomeService" (zip or maven-build) to the `<tomcat>/webapps` folder.
If there is already a folder named *mics-home-service* you have to delete it.
2. Navigate to your `apache-tomcat-8.5.24\bin` folder and start Tomcat by clicking on *startup.bat* (Windows) or executing *startup.sh* (Linux).
* Tomcat's default port is *8080*.
[source,text]
----
If 8080 port is already in use, you have to change tomcat's port as follows:
- Go to <tomcat>/conf folder
- Open server.xml file and search for "Connector port"
- Replace "8080" by your port number (for example 8181)
- Restart tomcat server (in the same folder which startup.bat is located, you can also find a shutdown.bat file).
----
IMPORTANT: If you change the port number you have also adapt the port in the
frontend project: File "<PRJ_plannedGridMeasuresFE>/proxy.conf.json"
[start=3]
3. Stop your the Apache Tomcat.
4. Navigate to `webapps/mics-home-service/WEB-INF/classes` and open *backendConfigProduction.json*
----
{
"micsDistributionCluster" : "openK",
"micsCentralURL" : "http://169.50.13.154:9010/mics/central",
"micsHealthStateExtraPath" : "healthcheck?pretty=true",
"micsCentralIsHttps" : false
}
----
[start=5]
5. Set the "micsCentralURL" accordingly. Change the IP to the server where the MicsCentralService Microservice is/will be installed on.
6. Start your Apache Tomcat.
=== Deploy and start Microservices
==== Microservices File Structures
No matter where the artifacts are from, a zip file from a Jenkins source or from a maven built
result (look at *howtoBuild*), the final structure and existence of the files/folders has to look
like the following layout (see File/Folder Structure below) after you deployed it to your chosen
folder.
a. If you got it as zip it should already has the correct structure after extraction. (ignore b.)
b. If you have a maven built:
* The needed jar-file is always in the `/target` folder of the related project folder after a successful maven build (look at *howtoBuild*).
The other files and folders needed are in the root folder `/` of the related project after a successful maven build.
==== MicsCentralService Backend-Microservice
===== File/Folder Structure
----
<yourChoosenFolder_MicsCentralService>/mics-central-service.jar
/serviceConfig_QA.yml
/servicesDistributionQAServer.json
----
===== Configuring and starting the microservice
The name of `*.yml` file can be changed but you have to use the same file as starting parameter when starting
the microservice later on. In our example it is `serviceConfig_QA.yml`.
*serviceConfig_QA.yml*
----
servicesDistributionFileName: servicesDistributionQAServer.json
logging:
level: INFO
appenders:
- type: file
currentLogFilename: /opt/mics/logs/mics-central-service.log
threshold: ALL
archive: true
archivedLogFilenamePattern: /opt/mics/logs/mics-central-service-%d.log
archivedFileCount: 5
timeZone: UTC
loggers:
org.eclipse.openk: DEBUG
org.eclipse.jetty.servlets: DEBUG
server:
applicationConnectors:
- type: http
port: 9010
adminConnectors:
- type: http
port: 9011
----
** servicesDistributionFileName: The file name of the configuration for the intercommunictaion between the services (see below).
** applicationConnectors: Type and port on which the microservice is running.
The latest set of socalled "service distribution cluster" can be found in the Architecture documentation.
*servicesDistributionQAServer.json*
----
{
"active": "true",
"clustername": "openK",
"description": "service cluster for openKonsequenz",
"distributions": [
{
"active": "true",
"name": "planned-grid-measures.openK",
"protocol": "http",
"host": "169.50.13.154",
"urlPath": "/mics/gridmeasures",
"portApp": "9050",
"portHealth": "9051",
"description": "Planned Grid Measures Backend"
},
{
"active": "true",
"name": "authNauth.openK",
"protocol": "http",
"host": "169.50.13.154",
"urlPath": "/portal/rest/beservice",
"healthUrlPath": "/portal/rest/beservice",
"portApp": "8080",
"portHealth": "8080",
"description": "Auth&Auth-Modul"
},
{
"active": "true",
"name": "mics-central-service",
"protocol": "http",
"host": "169.50.13.154",
"urlPath": "/mics/central",
"portApp": "9010",
"portHealth": "9011",
"description": "Mics Central Service-Configures and dispatches different service clusters for different modules"
}
]
}
----
** "name" : Name of the service (must not be changed, since it is hardwired in the client-applications!)
** "protocol" : HTTP or HTTPS
** "host" : IP of the server where the service can be reached
** "urlPath" : (must not be changed)
** "portApp" : Port of the service. For example for `mics-central-service` it is `9010` because that is
what we configured in the related `serviceConfig_QA.yml` under `applicationConnectors` -> `type` and `port`.
** "portHealth": Port of the dropWizard-Health-Service.
** "description" : Description of the service
The microservice can now be started via Java-Runtime in a console from your <yourChoosenFolder_MicsCentralService>:
Remember to use the *.yml file as parameter like below, in our example it is `serviceConfig_QA.yml`:
----
java -jar mics-central-service.jar server serviceConfig_QA.yml
----
TIP: It is recommend to install this execution as a service.
==== PlannedGridMeasures Backend-Microservice
===== File/Folder Structure
----
<yourChoosenFolder_PlannedGridMeasures>/planned-grid-measures.jar
/qserver.yml
/roleAccessConfiguration/role-access-definition.json
/emailConfiguration/mailTemplatesPaths.json
/emailConfiguration/emailTemplates/<MULTIPLE_EMAIL_TEMPLATES>.txt
----
===== Configuring and starting the microservice
The name of `*.yml` file can be changed but you have to use the same file as starting parameter when starting
the microservice later on. In our example it is `qserver.yml`.
*qserver.yml*
----
persistencyUnit: planned-grid-measures-devserver
portalBaseURL: http://localhost:8080/portal/rest/beservice
whiteListDocumenttypes: application/pdf,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel.sheet.macroEnabled.12,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-word.document.macroEnabled.12,image/png,image/jpeg
dbConn:
driver: org.postgresql.Driver
url: jdbc:postgresql://localhost:5432/plannedgridmeasuresqa
user: plgm_service
password: plgm_service
emailConfiguration:
smtpHost: localhost
port: 1025
sender: testSenderDevServer@test.de
logging:
level: INFO
appenders:
- type: file
currentLogFilename: /opt/mics/logs/planned-grid-measures.log
threshold: ALL
archive: true
archivedLogFilenamePattern: /opt/mics/logs/planned-grid-measures-%d.log
archivedFileCount: 5
timeZone: UTC
loggers:
org.eclipse.openk: DEBUG
org.eclipse.jetty.servlets: DEBUG
server:
applicationConnectors:
- type: http
port: 9050
adminConnectors:
- type: http
port: 9051
----
** portalBaseURL: The URL to the Auth&Auth Module (Backend)
** whiteListDocumenttypes: File types you want to allow for upload in *MIME-Type*
(https://wiki.selfhtml.org/wiki/MIME-Type/%C3%9Cbersicht)
** dbConn: Configuration of your postgreSQL database
** applicationConnectors: Type and port on which the microservice is running
The microservice can now be started via Java-Runtime in a console from your <yourChoosenFolder_PlannedGridMeasures>.
Remember to use the *.yml file as parameter like below, in our example it is `qserver.yml`:
----
java -jar planned-grid-measures.jar server qserver.yml
----
TIP: It is recommend to install this execution as a service.
TIP: Look at the *http://169.50.13.154/gridMeasuresADoc/architectureDocumentation.html[PlannedGridMeasures Architecture Documentation]* for informations about the services.
== How to deploy and run the Frontend
Go to `<tomcat>/webapps` folder, if there is already a folder named *plannedGridMeasures* delete it.
You can get the Frontend sources as a artifact (zip) from Jenkins or by a maven-build.
If you get the artifact from Jenkins as zip extract the content to the `<tomcat>/webapps` folder.
If you do a maven-build, copy the content of the `dist` folder in the project folder of "PlannedGridMeasures Frontend" to `<tomcat>/webapps/plannedGridMeasures`.
Nevertheless guarantee the following file/folder structure after extraction/copying:
----
<tomcat>/webapps/plannedGridMeasures
<tomcat>/webapps/plannedGridMeasures/index.html
<tomcat>/webapps/plannedGridMeasures/*.*
<tomcat>/webapps/plannedGridMeasures/assets/*.*
----