Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time

Managing Services

A lot of the software you will be installing, such as MySQL will need to run as background services. This tutorial will guide you through how to install and manage background services.

1 System D

https://www.linuxjournal.com/content/initializing-and-managing-services-linux-past-present-and-future

1.1 Installing Neo4J

In this section you will be shown how to install and run a Neo4J instance using SystemV. The database requires Java and all packages will be installed and managed by the apt package manager.

$ sudo apt install default-jre default-jre-headless
$ java --version
$ wget --no-check-certificate -O - https://debian.neo4j.org/neotechnology.gpg.key | sudo apt-key add -
$ echo 'deb http://debian.neo4j.org/repo stable/' | sudo tee /etc/apt/sources.list.d/neo4j.list
$ sudo apt update
$ sudo apt install -y neo4j
$ sudo service neo4j status
  ● neo4j.service - Neo4j Graph Database
     Loaded: loaded (/lib/systemd/system/neo4j.service; disabled; vendor preset: enabled)
     Active: active (running) since Wed 2019-08-07 13:05:12 BST; 22min ago
   Main PID: 1283 (java)
      Tasks: 53 (limit: 2200)
     Memory: 194.5M
     CGroup: /system.slice/neo4j.service
$ sudo service neo4j start
$ cypher-shell -u neo4j -p neo4j

The last command launches the cli tools which provides a shell where we can execute cypher queries. the command :exit quits the shell and returns you to the bash prompt. The following commands are executed in this shell. The first changes the password for the default account and the second retrieves all the nodes from the graph (currrently none). Note that each query needs to terminate with a semicolon.

neo4j> CALL dbms.changePassword('newPassword');
neo4j> CREATE (n:USER {name:"Test User"}) RETURN n;
neo4j> MATCH (users) RETURN users;
  +-----------------------------+
  | users                       |
  +-----------------------------+
  | (:USER {name: "Test User"}) |
  +-----------------------------+
  1 row available after 187 ms, consumed after another 2 ms
neo4j> MATCH (n) DETACH DELETE n;
  0 rows available after 262 ms, consumed after another 0 ms
  Deleted 1 nodes
neo4j> :exit
  Bye!

2 Docker

You can use the Docker Playground to learn how to work with Docker.

3 Homebrew (MacOS Only)

Until now all the tools and techniques covered work on the Raspberry Pi or indeed any computer running a Debian based Linux distribution (such as Ubuntu or Raspberian). If you are using a Mac (and MacOS) for your development work you should make use of the Homebrew package manager which provides commands to install, uninstall, update and run a wide range of software packages.

3.1 Installation

The installation instructions can be found on the main website, in summary you need to run the following in the terminal app which uses the Ruby language:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

3.2 Installing Packages

Once Homebrew has been installed you can use it in the terminal to install a wide range of software, for example to install MySQL:

  1. Search for the software on the Homebrew website. This tells you the correct software name, in this case it is mysql.
  2. Now we can install the software using brew install mysql.

3.3 Starting and Stopping Services

Many of the software packages run as background services and we need to be able to start, stop and restart these. The easiest way is to install the Homebrew Services using brew tap homebrew/services command. The tap subcommand allows you to access other repositories that are not included in Homebrew's master repository.

Once the services are installed you can list the installed services and see if they are running using the following command:

$ brew services list
  Name      Status  User Plist
  mosquitto stopped
  mysql     stopped
  neo4j     stopped

Now we can start and stop the services:

$ brew services start mysql
  ==> Successfully started `mysql` (label: homebrew.mxcl.mysql)
$ brew services restart mysql
  Stopping `mysql`... (might take a while)
  ==> Successfully stopped `mysql` (label: homebrew.mxcl.mysql)
  ==> Successfully started `mysql` (label: homebrew.mxcl.mysql)
$ brew services stop mysql
  Stopping `mysql`... (might take a while)
  ==> Successfully stopped `mysql` (label: homebrew.mxcl.mysql)