Git Product home page Git Product logo

account-payment-settings's Introduction

account-payment-settings

Account, payment and settings services all togther as mock online service

System run/start

Ubuntu:

1. Pre-requisites

  • Jenkins
  • Nginx
  • Maven
  • Java JDK

Installing Jenkins

  1. Open a shell terminal and add a new repository key to apt
wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add - 
  1. Now add the jenkins repository to the apt sources
echo deb http://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list
  1. Update the local database
sudo apt-get update
  1. And finally install Jenkins
sudo apt-get install jenkins

Setting up Jenkins

  1. Open a browser of your choice and navigate to
http://localhost:8081
  1. It will ask for a password. You can find it this way
sudo cat /var/lib/jenkins/secrets/initialAdminPassword

After submitting the password you will be prompted to create a new user. We entered admin as user name and password, but this is arbitrary and for testing purposes only!

Installing Nginx

  1. Update the local repositories
sudo apt-get update
  1. Install Nginx
sudo apt-get install nginx

Configuring Nginx

  1. Enable Nginx in firewall
sudo ufw allow 'Nginx HTTP'
  1. Restart Nginx
sudo service nginx restart
  1. Check that it works by navigating to http://localhost

Installing Maven

  1. Update the local repositories
sudo apt-get update
  1. Install Maven
sudo apt-get install maven

Installing Java JDK

  1. Update the local repositories
sudo apt-get update
  1. Install Java JDK
sudo apt-get install default-jdk

Now let's get started with the nitty gritty!

2. Creating a new task in Jenkins

  • Open a browser of your choice and navigate to
http://localhost:8080
  • Login with your user name and password

  • Click on New Task (left panel)

  • Enter account-payment-settings as task name (or anything else you see fit)

  • Select free style as project type

  • Click OK

  • In the Source code origin select git and use the following URL as Repository URL

https://github.com/xApiOrg/account-payment-settings.git
  • Scroll down and enable SCM, then enter the following command
H/02 * * * *
  • Finally, in the Run pipeline add the following steps

    • Maven tasks
     clean verify test install
    
    • Shell script
     echo "bash $(pwd)/target/dockerfile/run_linux.sh -k" | at now
    
    • Shell script
     echo "bash $(pwd)/target/dockerfile/run_linux.sh -r" | at now
    
  • Click Save

The service should start automatically with every build!

3. Expose the service with Nginx

The service will listen for requests on the port 10001 by default

We will redirect all the requests comming towards http://<host>/ipay to http://localhost:10001/ipay

  • Open a shell terminal and go to the available nginx virtual servers folder:
cd /etc/nginx/sites-available
  • Edit the default configuration with your preferred text editor:
nano ./default

You should see a location object already present in the file. It serves all requests comming to the root path /

  • Now add a new location object below it:
location /ipay {
	include /etc/nginx/proxy_params;
	proxy_pass http://localhost:10001/ipay;
}
  • Restart the Nginx server:
sudo service nginx restart
  • And check with a browser or curl that it is actually working!
http://<public-server-ip>/ipay/account/100

It shoud return:

Metod getAllUserPaymentAccounts( Integer userId) NOT IMPLEMENTED YET Get ALL User's PAYMENT accounts by user Id Parameters, user Id = 113 []

4. Manually starting and stopping the service

Open a shell terminal and move to the task's directory

cd /var/lib/jenkins/workspace/account-payment-settings
  • Starting the service

    • Generate the target folder
     mvn generate-resources
    
    • Start the service via the provided shell script
     sudo bash ./target/dockerfile/run_linux -r
    
  • Stopping the service

    • Generate the target folder
     mvn generate-resources
    
    • Stop the service via the provided shell script
     sudo bash ./target/dockerfile/run_linux -k
    

The run_linux.sh is a script writen to help run and kill the service.

To run the service use the parameter -r

To kill the service use the parameter -k

Please stop the service by yourself if you started it manually as Jenkins will have no permission to do so!

Windows:

1. Pre-requisites

  • Jenkins
  • Tomcat
  • Maven
  • Java JDK
  • Open Firewall ports

Installing Java JDK

  1. Download and install Java JDK
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
  1. Set environment variables
Create JAVA_HOME environment variable in System variables
Variable name: JAVA_HOME
Variable value: {jdkDirectory} (e.g.: C:\Program Files\Java\jdk1.8.0_144)

Edit Path environment variable in System variables and add %JAVA_HOME% to it

Installing Jenkins

  1. Download and install Jenkins for Windows
https://jenkins.io/download/

Setting up Jenkins

  1. Open a browser of your choice and navigate to
http://localhost:8080
  1. It will ask for a password. You can find it here
{jenkinsDirectory}/secrets/initialAdminPassword
  1. Change Jenkins port to 8081
Open {jenkinsDirectory}\jenkins.xml and change --httpPort=8080 to --httpPort=8081
  1. Restart Jenkins service
Open Windows services (win + r > services.msc), find Jenkins and restart it. After the restart the new Jenkins URL will be http://localhost:8081 

Installing Tomcat

  1. Download Tomcat
https://tomcat.apache.org/download-80.cgi

Configuring Tomcat

  1. Add and admin user
Open {tomcatDirectory}\tomcat-users.xml and edit it
<tomcat-users>
	<role rolename="manager-gui"/>
	<role rolename="manager-script"/>
	<user username="admin" password="admin" roles="manager-gui, manager-script"/>
<tomcat-users>

Installing Maven

  1. Download Maven
https://maven.apache.org/download.cgi
  1. Set environment variable
Edit Path environment variable in System variables and add your maven bin directory to it (e.g.: C:\Program Files\apache-maven-3.5.0\bin)

Firewall ports

To allow remote access to the applications, tomcat, jenkins... we need to open the port where the application is listening.

2. Creating a new task in Jenkins

  • Open a browser of your choice and navigate to
http://localhost:8081
  • Login with your user name and password

  • Click on New Item (left panel)

  • Enter account-payment-settings as task name (or anything else you see fit)

  • Select Freestyle project as project type

  • Click OK

  • In the Source Code Management select Git and use the following URL as Repository URL

https://github.com/xApiOrg/account-payment-settings.git
  • Scroll down and enable Poll SCM, then enter the following command
H/02 * * * *
  • Finally, in the Build pipeline add the following steps

    • Invoke top-level Maven targets
     generate-resources
    
    • Execute Windows batch command
     .\target\dockerfile\run_windows.bat /QT
    
  • Click Save

  • After every Jenkins build the application will be restarted. To try the application navigate to

http://<public-server-ip>:10001/ipay/account/100

The default port is 10001.

account-payment-settings's People

Contributors

burgazov avatar mfpousa avatar pablons avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.