How to install Wildfly on Mac

The easiest way is to install through Homebrew, the free open-source package managment system.

Install Wildfly

Download and install through brew package managment

macbookpro$ brew update
Already up-to-date.
macbookpro$ brew search wildfly
wildfly-as
macbookpro$ brew install wildfly-as
==> Downloading https://download.jboss.org/wildfly/10.0.0.Final/wildfly-10.0.0.Final.tar.gz
##########                                                                14.6%
==> Caveats
The home of WildFly Application Server 10 is:
  /usr/local/opt/wildfly-as/libexec
You may want to add the following to your .bash_profile:
  export JBOSS_HOME=/usr/local/opt/wildfly-as/libexec
  export PATH=${PATH}:${JBOSS_HOME}/bin
==> Summary
🍺  /usr/local/Cellar/wildfly-as/10.0.0.Final: 1,180 files, 153.4M, built in 7 minutes 18 seconds

And you are almost all set.

Add the environment variables

macbookpro$ cd /usr/local/opt/wildfly-as/libexec/bin
macbookpro$ ./standalone.sh
=========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /usr/local/opt/wildfly-as/libexec

  JAVA: java

  JAVA_OPTS:  -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true

=========================================================================

12:49:37,085 INFO  [org.jboss.modules] (main) JBoss Modules version 1.5.1.Final
12:49:38,033 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final
12:49:38,115 INFO  [org.jboss.as] (MSC service thread 1-6) WFLYSRV0049: WildFly Full 10.0.0.Final (WildFly Core 2.0.10.Final) starting
12:49:38,974 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
12:49:38,987 INFO  [org.xnio] (MSC service thread 1-6) XNIO version 3.3.4.Final
12:49:38,992 INFO  [org.xnio.nio] (MSC service thread 1-6) XNIO NIO Implementation Version 3.3.4.Final
12:49:39,023 WARN  [org.jboss.as.txn] (ServerService Thread Pool -- 54) WFLYTX0013: Node identifier property is set to the default value. Please make sure it is unique.
12:49:39,034 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 38) WFLYCLINF0001: Activating Infinispan subsystem.
12:49:39,038 INFO  [org.wildfly.extension.io] (ServerService Thread Pool -- 37) WFLYIO001: Worker 'default' has auto-configured to 16 core threads with 128 task threads based on your 8 available processors
12:49:39,046 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 44) WFLYJSF0007: Activated the following JSF Implementations: [main]
12:49:39,081 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 46) WFLYNAM0001: Activating Naming Subsystem
12:49:39,088 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 56) WFLYWS0002: Activating WebServices Extension
12:49:39,105 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 53) WFLYSEC0002: Activating Security Subsystem
12:49:39,111 INFO  [org.jboss.as.security] (MSC service thread 1-1) WFLYSEC0001: Current PicketBox version=4.9.4.Final
12:49:39,112 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 33) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
12:49:39,121 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 55) WFLYUT0003: Undertow 1.3.15.Final starting
12:49:39,121 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-5) WFLYUT0003: Undertow 1.3.15.Final starting
12:49:39,122 INFO  [org.jboss.as.connector] (MSC service thread 1-8) WFLYJCA0009: Starting JCA Subsystem (WildFly/IronJacamar 1.3.2.Final)
12:49:39,135 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-2) WFLYJCA0018: Started Driver service with driver-name = h2
12:49:39,159 INFO  [org.jboss.remoting] (MSC service thread 1-6) JBoss Remoting version 4.0.18.Final
12:49:39,194 INFO  [org.jboss.as.naming] (MSC service thread 1-5) WFLYNAM0003: Starting Naming Service
12:49:39,194 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-4) WFLYMAIL0001: Bound mail session [java:jboss/mail/Default]
12:49:39,317 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 55) WFLYUT0014: Creating file handler for path '/usr/local/opt/wildfly-as/libexec/welcome-content' with options [directory-listing: 'false', follow-symlink: 'false', case-sensitive: 'true', safe-symlink-paths: '[]']
12:49:39,347 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0012: Started server default-server.
12:49:39,349 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-3) WFLYUT0018: Host default-host starting
12:49:39,393 INFO  [org.jboss.as.ejb3] (MSC service thread 1-3) WFLYEJB0482: Strict pool mdb-strict-max-pool is using a max instance size of 32 (per class), which is derived from the number of CPUs on this host.
12:49:39,393 INFO  [org.jboss.as.ejb3] (MSC service thread 1-2) WFLYEJB0481: Strict pool slsb-strict-max-pool is using a max instance size of 128 (per class), which is derived from thread worker pool sizing.
12:49:39,457 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0006: Undertow HTTP listener default listening on 127.0.0.1:8080
12:49:39,541 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-5) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
12:49:39,647 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-2) WFLYDS0013: Started FileSystemDeploymentService for directory /usr/local/opt/wildfly-as/libexec/standalone/deployments
12:49:39,815 INFO  [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-1) ISPN000128: Infinispan version: Infinispan 'Mahou' 8.1.0.Final
12:49:39,815 INFO  [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-7) ISPN000128: Infinispan version: Infinispan 'Mahou' 8.1.0.Final
12:49:39,815 INFO  [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-3) ISPN000128: Infinispan version: Infinispan 'Mahou' 8.1.0.Final
12:49:39,872 INFO  [org.jboss.ws.common.management] (MSC service thread 1-5) JBWS022052: Starting JBossWS 5.1.3.Final (Apache CXF 3.1.4) 
12:49:40,088 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
12:49:40,088 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
12:49:40,089 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 10.0.0.Final (WildFly Core 2.0.10.Final) started in 3425ms - Started 267 of 553 services (371 services are lazy, passive or on-demand)

 [Optional] Add user to manage the server

macbookpro$ ./add-user.sh 
What type of user do you wish to add? 
 a) Management User (mgmt-users.properties) 
 b) Application User (application-users.properties)
(a): a

Enter the details of the new user to add.
Using realm 'ManagementRealm' as discovered from the existing property files.
Username : philippe.wanner
Password recommendations are listed below. To modify these restrictions edit the add-user.properties configuration file.
 - The password should be different from the username
 - The password should not be one of the following restricted values {root, admin, administrator}
 - The password should contain at least 8 characters, 1 alphabetic character(s), 1 digit(s), 1 non-alphanumeric symbol(s)
Password : 
WFLYDM0101: Password should have at least 1 digit.
Are you sure you want to use the password entered yes/no? yes
Re-enter Password : 
What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[  ]:    
About to add user 'philippe.wanner' for realm 'ManagementRealm'
Is this correct yes/no? yes
Added user 'philippe.wanner' to file '/usr/local/Cellar/wildfly-as/10.0.0.Final/libexec/standalone/configuration/mgmt-users.properties'
Added user 'philippe.wanner' to file '/usr/local/Cellar/wildfly-as/10.0.0.Final/libexec/domain/configuration/mgmt-users.properties'
Added user 'philippe.wanner' with groups  to file '/usr/local/Cellar/wildfly-as/10.0.0.Final/libexec/standalone/configuration/mgmt-groups.properties'
Added user 'philippe.wanner' with groups  to file '/usr/local/Cellar/wildfly-as/10.0.0.Final/libexec/domain/configuration/mgmt-groups.properties'
Is this new user going to be used for one AS process to connect to another AS process? 
e.g. for a slave host controller connecting to the master or for a Remoting connection for server to server EJB calls.
yes/no? no

Log in the management console

Go to http://localhost:9990/console/ and enter your credentials

Screen Shot 2016-07-03 at 13.11.03

And then you get your dashboard

Screen Shot 2016-07-03 at 13.14.26.png

How to install Wildfly on Mac

Java EE 7: The Big Picture

This is my personal summary of the book “Java EE 7: The Big Picture – Master the code, Applications, and Frameworks of Java Platform, Enterprise Edition 7” from Dr. Danny Coward.

Chapter 1: The Big Picture

Java EE Architecture

JavaEEPlatformArchitecture

  • Java EE container (‘Java EE’)
    • Runtime environment provided by the Java EE application server.
    • All the Java EE code runs in this environment.
    • Can mediate or intercept calls to and from the application code, and insert other kinds of logic that qualify and modify the calls to and from the application.
      Example: The security service that the Java EE container provides: the Java EE container can enforce security rules on the application that is running.
    • Supports a wide variety of protocols that clients may use to interact with a running Java EE application. Example: HTTP, WebSockets, RMI
    • Contains a variety of services that a Java EE application may choose to use:
      • Security: restrict access to its functions to only a certain set of known users.
      • Dependency Injection (DI): delegate the lifecycle management and discovery of some of its core components.
      • Transaction: define collections of methods that modify application data in such a way that either all the methods must complete successfully, or the whole set of method executions is rolled back as though nothing has ever happened.
      • Java Message Service (JMS): reliably send messages to other servers in the deployment environment of the Java EE application server.
      • Persistence service: enable application data in the form of a Java object to be synchronized with its equivalent form in the tables of a relational database.
      • JavaMail service: send email. Useful in the kind of application that take some action initiated by and on behalf of a user, and which needs to notify the user at some later time of the outcome of the action.
      • Java EE Connector Architecture (JCA): framework into which a new service that is not a standard part of the Java EE plaform may be added and that can then be utilized by a Java application running in the plaform.
      • Java Database Connectivity (JDBC) API: supports traditional storage and retrieval of Java EE application data in a relational database using the SQL query language.
  • Web container
    • Runs the web components: web pages, Java servlets, and other web components that can interact with clients connecting to the Java EE application with standard web protocols.
  • Enterprise JavaBeans (EJB) container 
    • Runs the application logic
    • EJB are Java classes that contain and manipulate the core data structures
  • Database tier
    • Holds all application data that the Java EE application needs to exists longer than the scope of a single session of the application, or simply between different steps in the application that are separated in time.

Hello World Application

helloWorldApplication

Structure of the Java EE application

  • DisplayServlet is responsible for :
    • rendering the web page seen from the browser
    • creating the HTML elements that make up the web page
    • displaying the message that the Java EE application is holding
  • WriteServlet is responsible for:
    • processing the message that is input to the application
    • passing the hello-message and formulates a Java object from the Message class that is part of the application
    • passing the message to an Enterprise Bean component, called ModelEJB.
  • ModelEJB is responsible for:
    • processing the message and formulates a Java object from the Message class.
    • storing the message object in the database using the Java Persistance API (JPA).
    • retrieve the message in DB on behalf of the DisplayServlet, when the servlet needs to create the web page to display.

Roles

  • Browser client: render the HTML content that the Java EE application creates for it, and send a message typed in by the user.
  • Web components (DisplayServlet and WriteServlet): create the HTML content for the browser and to direct the incoming user message to the correct portion of the application that can handle the message processing logic (ModelEJB).
  • ModelEJB: process, store and retrieve the user message to the database.

WriteServlet code

The browser formulates an HTTP POST request and sends it to the Java EE server, to a URL that will look like http://localhost:8080/HelloJavaEE-war/WriteServlet. As you shall see, the WriteServlet is mapped to the WriteServlet, and because of this fact, the Java EE server routes the HTTP POST request to the WriteServlet. Remark: this web component intercepts HTTP POST requests, because it has a doPost() method. WriteServlet is a HttpServlet.

@WebServlet(name = "WriteServlet", urlPatterns = {"/WriteServlet"})
public class WriteServlet extends HttpServlet {
  @EJB
  private ModelEJB ModelEJB;
  private static String PUT_MESSAGE = "put_message";

  @Override
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String message = request.getParameter(PUT_MESSAGE);
    if ("".equals(message)) {
      ModelEJB.deleteMessage();
    } else {
      try {
        ModelEJB.putUserMessage(message);
      } catch (MessageException nme) {
        throw new ServletException(nme);
      }
    }
    response.sendRedirect("./DisplayServlet");
} }

Notice that there is no constructor. In fact, the Java EE containers manage the lifecycle of components. In particular, the web container manages the lifecycle of Java servlet components, so the developer can focus on the application logic instead.

ModelEJB code

The ModelEJB is an Enterprise Bean, which is mostly a Plain Old Java Object (POJO).

@Stateful
public class ModelEJB {
  @PersistenceUnit
  private EntityManagerFactory emf;
    
  public void putUserMessage(String messageString) throws MessageException {
    this.deleteMessage();
    try {
      String decodedMessage = URLDecoder.decode(messageString, "UTF-8");
      Message message = new Message("1", "(" + messageString + ")" + " in a database");
      EntityManager em = emf.createEntityManager();
      em.persist(message);
    } catch (UnsupportedEncodingException uee ) {
      throw new MessageException("something odd about that message..." + messageString);
    }
  }

  public String getStoredMessage() throws MessageException {
    EntityManager em = emf.createEntityManager();
    List messages = em.createNamedQuery("findMessages").getResultList();
    if (messages.size() > 0) {
      Message message = (Message) messages.get(0);
      return "(" + message.getMessageString() + "), inside an EJB";
    } else {
      throw new MessageException("There was nothing in the database.");
    }
  }

  public void deleteMessage() {
    EntityManager em = emf.createEntityManager();
    em.createNamedQuery("deleteMessages").executeUpdate();
} }

What makes this Java class an Enterprise Bean is the annotation @Stateful. This means that the Enterprise Bean container will create one instance of the bean for each client that talks to it.

Message class code

Looks like a normal class but has been annotated with @Entity. Because of that it can be persisted and managed within a database.

@Entity
@Table(name = "MESSAGE")
@NamedQueries({
  @NamedQuery(
    name="findMessages",
    query="select m from Message m"),
  @NamedQuery(
    name="deleteMessages",
    query="delete from Message"
  )
})
public class Message implements Serializable {
  @Id
  @Column(name = "ID")
  private String id;

  @Column(name = "MESSAGE")
  private String messageString;
  public Message() {
  }

  public Message(String id, String messageString) {
    this.id = id;
    this.messageString = messageString;
  }

  ... //getters and setters
}

DisplayServlet code

This servlet queries the ModelEJB for the stored message and create the HTML that forms the web page that is shown to the user. It has a doGet() method so that it will intercept any HTTP GET requests.

@WebServlet(name = "DisplayServlet", urlPatterns = {"/DisplayServlet"})
public class DisplayServlet extends HttpServlet {
  @EJB
  private ModelEJB modelEJB;

  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    try {
      out.println("<html>");
      out.println("<head>");
      out.println("<title>Hello Java EE</title>");
      out.println("</head>");
      out.println("<body>");
      out.println("Enter a message for Java EE which will pass through the web tier, the EJB tier to the database, and back again !");
      out.println("<form action='./WriteServlet' method='POST'>");
      out.println("<input type='submit' value='Enter'>");
      out.println("<input type='text' name='put_message'> ");
      out.println("</form>");
      String displayMessage;
      try {
        String storedMessage = modelEJB.getStoredMessage();
        displayMessage = "Hello from (" + storedMessage + "), inside a web component";
      } catch (MessageException nme) {
        displayMessage = "you should enter a value...";
      }
      out.println("The current message from Java EE: <br><b>" + displayMessage + "</b>");
      out.println("</body>");
      out.println("</html>");
    } finally {
      out.close();
} } }

The Many Variations of Java EE Applications

Many Flavors of Web Interface

  • Original purpose: replace CGI programming and kind of all-purpose server-side component model for handling any request/response style network protocol, not just HTTP.
  • Inconvenience: as seen, embedding HTML inside Java code is too cumbersome approach. But Java EE offers a superior web component model to generate dynamic web content for browsers of all kinds: JavaServer Pages (JSP) and JavaServer Faces (JSF). Both are based on Java servlets.
  • Java EE platform contains a variety of web components that can handle and respond to incoming web service calls. Known as Java Web Service components, these components are to both Simple Object Access Protocol (SOAP) and to Representational State Transfer (REST) web services what Java servlets, JSPs, and JSF are to HTML content.
  • WebSockets are web components that give a server component the ability to send data out to interested clients.

Many Kinds of Application Logic

  • Statefull session beans
    • are instantied by the EJB container each time a new client wishes to uses it.
    • hold its application state for each of its connected clients.
    • E.g.: shopping cart
  • Stateless session beans
    • are brought into existence  each time they are called.
    • perform very well in large-scale systems, beause these beans are instantiated only when needed and can easily be instantiated on a node in a cluster.
  • Singleton session beans
    • are ideal for representing an application state that is common to all connected clients of the application
    • are instantiated only once in the Java EE application
    • E.g.: modeling a news feed viewable by all logged-in users, or a high score table.
  • Message-driven beans
    • offer a programming model wherein instead of making method invocations, tasks are initiated by sending a message, with task completion occuring asynchronously with the sending of another message.
    • Well suited for long-running activities, such as backing up large amounts of data, handling a complicated purchase order.

Different Ways to Store Application Data

  • JPA (Java Persistence API) offers a high-level framework with which applications perform object-relational mapping: data objects you want to model can easily be translated into equivalent data tables in a relational database, which can be a shortcut to designing relational schemas and the various queries needed to store and retrieve the data.
  • JDBC (Java Database Connectivity) API models connections to the relational database and the execution of SQL statements to store, manage, and retrieve that data.
  • Java Transaction API allows multiple activities to be grouped into a single atomic action that either succeeds, meaning each member of the atomic action succeeds, or fails, in which case the individual activities that completed before the failure are reversed, in which case the overall effect is as though nothing had happened.

Interfacing with Other Systems

  • Java web services APIs
    • not a framework of reliable messaging
    • allows for loosely coupled interactions, where systems evolve and add functionality separately from their peers without disrupting a working system.
    • E.g.: analytics servers, purchasing systems, order management servers
  • Java Message Service
    • provides reliable asynchronous message mechanism
    • E.g.: financial purchase transaction, ordering a part number, or requesting a delivery scheme in order to complete its work.
  • Java EE Connector Architecture
    • is a all-purpose extensibility mechanism
    • enables a class of Java EE applications that uses it to rely on arbitrary external information systems.

Packing and Deploying the Hello Java EE Application

The Hello Java EE application consists of web components and an Enterprise Bean and data code.

Web ARchive file (WAR)

  • is the vehicle for deploying the web components in a Java EE application
  • is a kind of ZIP file, with a predefined structure consisting of a
    • root directory to hold any textual web pages such as HTML pages, JSP, or JSF files.
    • /WEB-INF directory under which any Java class files they need, such as Java servlets, are held, in addition to other configuration information.
/META-INF
   /MANIFEST.MF
/WEB-INF
   /classes
      /javaeems
         /web
            /DisplayServlet.class
            /WriteServlet.class

Enterprise Bean JAR

  • packages the Enterprise Bean code in a archive
  • uses the /META-INF directory to store configuration information about the Enterprise Beans it contains, together with the class files that the beans use at the root level of the archive.
  • held the persistence.xml in the META-INF directory to ensure that ModelEJB can access the database through the Java Persistence layer.
/META-INF
   /MANIFEST.MF
   /persistence.xml
/javaeems
   /model
      /ModelEJB.class
      /Message.class
      /MessageException.class

Enterprise ARchive (EAR)

  • allows a Java EE application to be packed into one single, self-contained file.
  • /META-INF held the configuration information
/META-INF
   /MANIFEST.MF
/HelloJavaEE-jar.jar
/HelloJavaEE-war.war

Screen Shot 2016-06-18 at 21.48.18.pngOnce a Java EE application has been package into this form, it can be deployed to any Java EE server.

 

Java EE 7: The Big Picture

How to install WildFly on Windows

Formerly known as JBoss AS or simply JBoss, WildFly is a fantastic full-featured multiplaform open-source and free application server authored by Red Hat.

This quick tutorial will list the steps to install this AS on a Windows machine.

PREREQUISITE: Install the lastest Java Development Kit (JDK)

To be able to run the AS, you will need a compatible JDK (JDK 7 Update 75 or later), if possible the lastest available on the Oracle website.

  1. Go to this link and download the lastest JDK (e.g. jdk-8u91-windows-x64.exe).
  2. Change the installation directory to c:\Java\jdk{your-version} (e.g. jdk1.8.0_91)screen1This should be like:screen2
  3. Create an environment variable JAVA_HOME for your system.
    1. On your keyboard, press windows+break
    2. Click on ‘Advanced System Configuration’
    3. Under ‘Environment variables’, add the variable JAVA_HOME with values ‘c:\Java\jdk{your-version}’screen3
    4. And add it to the Path variablescreen4
    5. You will need to close any command windows that were open before executing a command with this path, since there is no way to reload environment variables from an active command prompt.
    6. To check if the path variable is correctly configured, type ‘javac -version’ in the prompt. This will give you the version of the java compiler you installed.screen5

Installing WildFly 10

  1. Download the lastest stable version of the Enterprise Application Integration (EAI) server from the official website (Link). (E.g. wildfly-10.0.0.Final.zip)
  2. Extract the zip archive to C:\EAI. Your system will create a brand new folder named ‘wildfly-10.0.0.Final’ under C:\EAI.
  3. Execute the script ‘C:\EAI\wildfly-10.0.0.Final\bin\standalone.bat‘ to set up the bootstrap environment, check the installation and start the server.screen6
  4. After that the server has been started, you should be able to access the web server at the address http://localhost:8080 and to access to the console at http://localhost:8080/console.screen7

Configure WildFly server

Add a user to access to the console

To be able to access the admin console, you will need to add a new user by executing the script ‘add-user.bat’ located under your WildFly installation folder (e.g. c:\EAI\wildfly-10.0.0.Final).

  1. Execute the script ‘add-user.bat’ in a console window.
  2. Add a Management User by just typing ‘enter’ since this is the default option.screen0
  3. Enter the details of the new user to add as described. (e.g. ‘admin’ and ‘1234’ for a local installation).
  4. Revisit the server console at localhost:9990/console and enter your credentials.
  5. Now, you should be able to see thisscreen1
How to install WildFly on Windows

Create Swapfile on Raspberry Pi and Miniban

While using Bittorrent Sync on my Raspberry Pi, I had some issues with BTSync using too much RAM. To solve this problem I decided to create a 2GB (count=2097152) swap file and see how it would perform. To do this follow these steps:

  1. Create a swap file in your filesystem replace “/PATH/FILENAME” and “SWAP_SIZE” with desired values. “SWAP_SIZE” is in kilobytes:
    the “dd” command can take up to 5 minutes, depending on how big “SWAP_SIZE” is.

    dd if=/dev/zero of=/PATH/FILENAME bs=1024 count=SWAP_SIZE
    chmod 600 /PATH/FILENAME
    mkswap /PATH/FILENAME
    swapon /PATH/FILENAME
  2. Add the swap file to the fstab list:
    sudo nano /etc/fstab
    #Swap file
    /PATH/FILENAME none swap sw 0 0

I’m using RPi-Monitor and can easily see if the Swap file is in use now

Statistics

raspimonitor_noSwap
Before without swap file
raspimonitor_Swap
After with swap file

RAM usage

SWAP usage

So I created a Swap partition on the 8th of February, this reduced RAM usage significantly.

Create Swapfile on Raspberry Pi and Miniban

Babun Shell

I want to point out a tool I cannot live without anymore on Windows. It is called Babun and is based on Cygwin.

Like Cygwin it brings basic POSIX commands and some features found in any Linux distribution to Windows. So what’s special about Babun? Here is a non-exhaustive list of its key features:

  • Preconfigured and ready to run
  • easy GIT integration
  • Features a package manager
  • nice visual features like syntax highlighting
  • Automatic updates

A lot more features can be checked out on their website http://babun.github.io/

Babun Shell

How to immediately lock your screen in OSX

I never found a way to lock the screen convenient to prevent intrusive people to look at my documents. Actually this functionality present on Windows (windows-key+L) also exists on Mac. Here is the way:

To enable this feature, you will have to go to System Preferences -> Security & Privacy and to the tab General. Then check the box “required password”and set an interval that meets your needs.Screen Shot 2016-01-11 at 12.36.23.png

Now you can lock the screen; simutaneously press Ctrl + Shift + Power (or Ctrl + Shift + Eject for older Macs).

Another handy key combination is Cmd + Option + Power (respectively Cmd + Option + Eject for older Macs) to put your mac into sleep mode.

 

 

How to immediately lock your screen in OSX

Build your own stackable Raspberry Pi Tower (part 5)

Conclusion

What an adventure! After 4 evenings, here it is, a beautiful and sexy tower! Light, stable, scalable and stackable.

the result

Photo 24-08-15 22 09 37
Philippe’s tower
Photo 29-08-15 00 17 18
Tobias’s tower

The video

What’s Next?

A Raspberry Tower without system installed would be like a car without wheels… not so usable and bit too expensive. Here are some ideas we had. I hope it will inspire you for your project.

rbpi
Here we have the Raspberry Pi Monitor from one of our RPis with load over the last two days.
Build your own stackable Raspberry Pi Tower (part 5)

Build your own stackable Raspberry Pi Tower (part 4)

Assembly

After we finalized our plans and all the stuff we bought online slowly made its way from China to Switzerland, we could start assembling the tower. We started by constructing the frame.

Photo 19-06-15 18 43 29
Concentrated

Frame

The Frame is made of 4 aluminum bars on each corner. They are held together by threaded rods, nuts and bolts.

IMG_20150824_201326
Close up of the frame

The first step is to drill holes into the aluminum bars. In the end The Acryl Glass will sit on the threaded rod and will create a “level”. So we had to think and calculate the distances between the holes. We also took into account of how high a Raspberry Pi v1 and v2 is.

Photo 19-06-15 17 44 41

levels

As you have seen on our plan, we chose to have 4 “levels”. They are made of 5mm acryl glass.

Photo 13-07-15 18 26 09
The frame is almost finished

The cutting plans with and without holes can be downloaded here:

Tier_v0.3.vsd
Tier_v0.4_1.vsd
Tier_v0.4_1.dxf

IMG_20150603_201747
Laser cutting

The “levels” where the Raspberry Pis sit should also have some kind of drawer mechanism, so that we can pull the Pi holder out easily. This is made with the curtain rails we bought from a local store. The holes in the cutting plans serve as screw holes.

Photo 24-08-15 20 27 39

Raspberry Pi holder

The Raspberry Pi holder is a piece of acryl glass where the Raspberry Pi is mounted. We made plans to cut holes for a Raspberry Pi, but you can adjust them to mount a 2.5″ hard drive for example.

Pi_holder_0.6.vsd
Pi_holder_0.7.dxf

The Pi holders with Raspberrys

Stabilizer

Unfortunately the structure wasn’t stable enough. A solution we found, was to cut long traversal pieces and mount them on each side of the tower. This resulted in a massive improvement of stability.

stabilizer_0.1.vsd
stabilizer_0.1.dxf

Photo 24-08-15 20 18 17

Decoration

As engineers we’re not really gifted in creating art and decoration. But we tried our best and decorated the tower. So we made plans to engrave acryl glass and mount it on the front of the tower.

drawing_0.0.vsd

Tobias FIechter’s masterpiece
Philippe Wanner’s masterpiece
Build your own stackable Raspberry Pi Tower (part 4)

Build your own stackable Raspberry Pi Tower (part 3)

Material

Before building the tower we had to organise and buy some material. Here is a shopping list which can be used as an example to build the tower. As mentioned before, we could use some really great tools like the laser cutter and professional drilling tolls from the FabLab Bern. If you don’t have access to such tools a short search on Google will probably help (like how to cut Acryl Glass).

Shopping list

All the stuff can be found on Amazon, Ali Express, Element14 or local stores

  • 3mm x 1500mm x 500mm and 5mm x 1500mm x 500mm Acryl Glass
  • 4x Aluminium bars
  • 1.5m curtain rail
  • enough bolts and nuts 3M & 2.5M
  • 2x 1500 threaded rod 3M
  • 20x plastic standoff 2.5M

Photo 19-06-15 17 44 54

  • USB Hub which can support 5x 5V
  • 10Port Ethernet Switch
  • 5x Ethernet Cable
  • 5x Micro USB Cable (for power supply)
  • 5x Rasperry Pi 2
  • 5x Micro SD Card
Photo 08-06-15 18 53 42
Finally some cool new hardware!

Tools

  • ThunderLaser Lasercutter (for cutting Acryl Glass)
  • drilling machine
  • hacksaw
  • all kind of tools to tighten screws and so on
  • … and beers to keep the efficiency high  😉
IMG_20150603_212647
hard working

Software

  • Visio – Microsoft Office
  • LaserGraph – ThunderLaser
  • Dropbox (for teamwork)

Photo 08-06-15 18 50 36

Build your own stackable Raspberry Pi Tower (part 3)

Build your own stackable Raspberry Pi Tower (part 2)

Draw the concept

Forword

I would say that the concept is the most important part of all! If you forget to think about the details, the cost will be higher, you will be wasting more time or your project will be useless. So, be aware! But keep in mind that “a simple concept is usually the better one”! Don’t do over-engineering!

IMG_20150824_201315
Almost finished tower with stabilization

We have drawn 2-3 concepts before we were convinced we got the one which could be our best shot. To get some inspiration, we searched the Internet for some other Raspberry Pi Tower projects.  We were happily surprised that the official Raspberry Pi forum is full of amateur projects and ideas. Our concept was inspired great ideas and mistakes of other projects.

Requirements

Let list some properties we want for this tower:

  • Scalable
  • Medium size (even if it is suggestive what medium means)
  • Modulable
  • Maximum 200$ with 4 RPis
  • Can be easily carried from place to place (it would be nice if we could take our prototype home…)
  • Can be prepared and assembled in less than one day

Draw the concept

In a logical way, we should draw the concept before going to the online-shop and buy thousands of things we won’t need. Here are the drafts we made.

First draft

blog-concept-first-v0.0

Pro / Cons:
– Waste of space (only a few RPis can be placed on each level)
– Cable management: the RPis are not near to each other
– A fifth additional RPi would need a new level
+ Modularity: Each level can be swapped and they are similar

 

Second draft

blog-concept-second-v0.0

Pro / Cons:
– Scalability: the height of each RPi stack is very limited
– Cable management
– Access to each module

– Stack stability
+ Modularity
+ Space management

Final concept

blog-concept-final-v0.2

Pro / Cons:
+ Modularity
+ Extensibility
+ Scalable
+ Cable management
+ Easy access to each module
+ Space management
+ Each blade can contain a RPi, HD, SSD, Arduino, …
– Each RPi has to be mounted on a blade

Other concepts

Bitcoin mining Tower: How to make stackable tower Gridseed Rig with Raspberry Pi!

120 Raspberry Pi cluster: What would you do with 120-Raspberry Pi Cluster?

Build your own stackable Raspberry Pi Tower (part 2)