Setup SCDE RpServer - With Jenkis Traffic Light

by AdamL92 in Circuits > Raspberry Pi

1747 Views, 29 Favorites, 0 Comments

Setup SCDE RpServer - With Jenkis Traffic Light

Untitled Diagram.png

Super Cool development environment (SCDE) is cheap solution for those who don't have money for expensive severs and are tired of reinstalling their OS, wanna test all cool stuff for webdevelopment or just have own private git repository or cool jenkins TraficLight :)

let's get started

1. What Is SCDE

LION_arch.png

SCDE it's just computer (rasbperry pi) which has preinstalled everything for modern developer. I program a lot of in java, javaScript frameworks and Arduino so I build this for me in first place. There are lot of very good tutorial's how setup Git, apache on raspberry pi so for that I will just paste link. For other I will do step by step tutorial without omitting steps.

List of software we'll use:

  1. Java, Python, Node JS
  2. Serves : Tomcat, Apache, Wildfly, Glassfish
  3. Db: MySql, PostregSql
  4. Building tools: Gradle, Maven, Grunt
  5. CI - Jenkins

2. Prepare Raspberry Pi and Install 'Power' (java, Python Etc) and Setup Static Ip :)

Lets update and upgrade Rp.

Install RASPBIAN JESSIE LITE image after that.

sudo apt-get update

sudo apt-get upgrade

Than setup static Ip address

https://www.modmypi.com/blog/tutorial-how-to-give-...

Release storage in Rp

sudo raspi-config

select '1 Expand Filesystem'

for more config

https://www.raspberrypi.org/documentation/configuration/raspi-config.md

Install Java :)

Type to terminal java -version if you will get than install java

-bash: java: command not found

Type

sudo apt-get install openjdk-8-jdk

Than try type

java -version

javac -version

pi@raspberrypi:~ $ java -version<br>openjdk version "1.8.0_40-internal"
OpenJDK Runtime Environment (build 1.8.0_40-internal-b04)
OpenJDK Zero VM (build 25.40-b08, interpreted mode)


pi@raspberrypi:~ $ javac -version
javac 1.8.0_40-internal

Setup JAVA_HOME

Open .bashrc on bottom of file write

sudo find /usr/ -name *jdk
export JAVA_HOME=/usr/share/doc/openjdk-8-jdk

export PATH=$JAVA_HOME/bin:$PATH

Than type echo $JAVA_HOME and you should get something like this:

pi@raspberrypi:~ $ echo $JAVA_HOME<br>/usr/share/doc/openjdk-8-jdk/

Install Python

It is already installed on my version :)

Install node Js

I use the first method with nvm manager

http://www.hostingadvice.com/how-to/install-nodejs-ubuntu-14-04/

For the last Install Git

type

sudo apt-get install git

Congratulations you have successfully configure your SCDE

Setup SSH key for no login access

Follow this tutorial

https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md

3. SERVERS SERVERS CAN I Have Some Servers ?

57d2c09d4fbade66f500083f.jpeg

Modern webdeveloper is useless without arsenal of servers. In this part we will install most famous app server Tomcat than java web servers like WILDFLY GlassFish and most popular http server Apache hope you'll ejoy

Port list

This is is list of ports for individual servers

  1. Tomcat: 8082
  2. Apache 80
  3. Wildfly: 8081
  4. GlassFish: 8083
  5. Node apps from 8084 - to 8085
  6. Java standalone wepApp from 8085 - 8095
  7. Other python or .. servers 8095 8100
  8. MySql : 3306 default
  9. PostgreSql: 5432 default

Firstly create directory under Home called servers

mkdir servers

Tomcat

Download Tomcat from this link

http://tux.rainside.sk/apache/tomcat/tomcat-7/v7.0.70/bin/apache-tomcat-7.0.70.tar.gz

Than extract files to ~/servers/tomcat.

mkdir ~/servers/tomcat
cd ~/servers/tomcat/
tar -xvf ~/Downloads/apache-tomcat-7.0.70.tar.gz --directory .

Set port in tomcatFolder/conf/server.xml

<Connector port="8082" protocol="HTTP/1.1"

	conncetionTimout="20000"

	redirectPort="8443"

	address="0.0.0.0" />

Starting the beast

cd ~/servers/tomcat/%tomcatVersion%/bin 

./startup.sh
ps aux | grep tomcat

You should in process something like this

pi@raspberrypi:~/servers/tomcat/apache-tomcat-7.0.70/bin $ ps aux | grep tom

root     31472 17.2  6.0 351808 57304 pts/0    Sl   14:58   1:10 /usr/bin/java -Djava.util.logging.config.file=/home/pi/servers/tomcat/apache-tomcat-7.0.70/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.endorsed.dirs=/home/pi/servers/tomcat/apache-tomcat-7.0.70/endorsed -classpath /home/pi/servers/tomcat/apache-tomcat-7.0.70/bin/bootstrap.jar:/home/pi/servers/tomcat/apache-tomcat-7.0.70/bin/tomcat-juli.jar -Dcatalina.base=/home/pi/servers/tomcat/apache-tomcat-7.0.70 -Dcatalina.home=/home/pi/servers/tomcat/apache-tomcat-7.0.70 -Djava.io.tmpdir=/home/pi/servers/tomcat/apache-tomcat-7.0.70/temp org.apache.catalina.startup.Bootstrap start
pi       31524  0.0  0.1   4248  1404 pts/0    S+   15:05   0:00 grep --color=auto tom

Apache (with mysql and wordpress)

There is a lot of great tutorials for setup apache MySQL and WordPress will be installed later

https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/

Wildfly

Very similar like Tomcat first download latest version of WildFly.

mkdir ~/servers/wildfly && cd ~/servers/wildfly/
wget http://download.jboss.org/wildfly/10.1.0.Final/wildfly-10.1.0.Final.tar.gz

http://wildfly.org/downloads/

Than you need to setup port in standalone.xml file and biding address for remote access

Change biding address of management tool and server.

Than on bottom of standalone.xml change number of server port to "8081"

GlassFish

Create glassFish directory under servers directory

mkdir glassFish && cd glassFish

wget http://download.java.net/glassfish/4.1.1/release/glassfish-4.1.1.zip

I use this tutorial to make it live

https://blog.idrsolutions.com/2014/02/tutorial-setting-up-glassfish-on-a-linux-server/

Be carefuller wait for sever starts it take some time.

Health check scripts

https://www.the-hawkes.de/monitor-your-raspberrypi...

4. Setup Databases

MySQL

Install mysql database following this tutorial
https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/worksheet/

!!!!!!! beware this will make your DB accessible in network only for Developing purpose

$ mysql -u root -p

$ Enter password:

$ mysql use mysql

$ mysql GRANT ALL ON *.* to root@'192.168.1.4' IDENTIFIED BY 'your-root-password';

$ mysql FLUSH PRIVILEGES;

PostgreSQL

This was hard one because I did't get rid off perl erros connect with local problems... but this is solution for you

http://daker.me/2014/10/how-to-fix-perl-warning-setting-locale-failed-in-raspbian.html

$ sudo dpkg-reconfigure locales

$ select en_US.UTF-8

$ select en_US.UTF-8

sudo locale-gen en_US.UTF-8

$ type "locale" to check again.

Tha you get rid of this error

$ perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = "en_US.UTF-8",
	LC_ALL = "en_US.UTF-8",
	LC_PAPER = "sk_SK.UTF-8",
	LC_ADDRESS = "sk_SK.UTF-8",
	LC_MONETARY = "sk_SK.UTF-8",
	LC_NUMERIC = "sk_SK.UTF-8",
	LC_TELEPHONE = "sk_SK.UTF-8",
	LC_IDENTIFICATION = "sk_SK.UTF-8",
	LC_MEASUREMENT = "sk_SK.UTF-8",
	LC_TIME = "sk_SK.UTF-8",
	LC_NAME = "sk_SK.UTF-8",
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
psql: could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

Tha run

$ sudo apt-get update && sudo apt-get upgrade

$ sudo apt-get purge postgresql*

$ sudo apt-get -f install 

$ sudo apt-get install postgresql

Than you have to set password for postgres user

$ sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"

Done! You saved User = postgres and password = postgres. If you do not have a password for the User postgres

$ sudo passwd postgres

Than you have to setup PgDb for remote access

su - postgres

Add or edit the following line in your /etc/postgresql/9.4/main/postgresql.conf :

listen_addresses = '*'

Add the following line as the first line of /etc/postgresql/9.4/main/pg_hba.conf. It allows access to all databases for all users with an encrypted password:

# TYPE DATABASE USER CIDR-ADDRESS  METHOD
host  all  all 0.0.0.0/0 md5

Than restart posgtres

sudo /etc/init.d/postgres restart

Try to connect to db with PgAdmin.

Install and Setup Jenkins

This was not that easy.. if you wanna use NodeJs okay so lets go.

Install jenkins following instructions on this site:

http://www.duskborn.com/installing-jenkins-on-rasp...

I have my personal web which is powered by grunt task runner, bower for installing dependencies and so on.

And fortunately nodeJS plugin for jenkis doesnt work on Rp.

But I have workaround for you. This instruction is against security rules but this servers is only in your home network so ... is not that big deal, but if you want proper security you have to find another tutorial for that maybe next time :).

WorkAround

Open visudo and at this lines

jenkins ALL=(ALL) NOPASSWD: ALL
# Members of the admin group may gain root privileges.<br>%admin  ALL=(ALL) NOPASSWD:ALL

Than log as jenkins

su jenkins

and install node, npm, bower, grunt etc/

sudo apt-get install nodejs
sudo apt-get install npm
sudo ln -s /usr/bin/nodejs /usr/bin/node
sudo npm install -g bower
sudo npm install -g grunt-cli

Yea I know this is not good way but works now...

Setup test task

I have my portfolio web site Like I said on pictures you can see my setup for CI.

This tutorial is only for setup things not to use it so if you have better solution for jenkins and NodeJs give my advice I'll appreciated that.

List of HW Materials

20160909_092743.jpg
20160909_092913.jpg
20161028_185206.jpg
20161028_185237.jpg
20161028_185302.jpg
20161028_185313.jpg
20161028_185331.jpg
20161028_185338.jpg
20161028_185404.jpg
20161028_185416.jpg
20161028_185423.jpg
20161028_190008.jpg

What you will need...

  1. plastic electric box (Shop in EU)
  2. DC converter from 12V DC to 5V DC (From ebay)
  3. 4 relay module (from ebay)
  4. 3 big leds buy in local radio-shack shop
  5. 3 resistors
  6. Cables for arduino wiring
  7. DC 3.5 female plug
  8. 12V DC power suplly
  9. PCB stands get from ebay (somethinglike this from ebay)

Build Traffic Light

Sorry I don't have video how I build traffic light but it is not that hard jut drill few holes a put everything together.
I will provide later completely schematic for wiring inside the box if somebody wants email me (adamluptakosice@gmail.com).

Before

Before you build the whole thing, Test first :) TDD in action, buy relay module with Led signalization. I used tutorial from this site and connection everything works for the first time :) http://antonfisher.com/posts/2016/01/05/make-rasp...

So If you follow tutorial in the link you will have working jenkis Traffic light is not that hard just make every connection properly.

Try to add some test project Like I add put there sleep echo etc. a try if its flasing check my video.

Finish

20161017 220048

Hope you enjoy this tutorial please check youtube video and give me feedback thanks.

See you soon ADIOS from SLOVAKIA A.L