Install a Plastic server on Raspberry Pi

Sunday, February 01, 2015 0 Comments

UPDATE 2015/06/16 by Sergio: added daemon auto-start instructions.

Installing a Plastic SCM server on a small Raspberry box is a straightforward process. Once you get Mono setup, you can download our “zip server distro” and get it up and running in seconds.

This blogpost explains the process step by step.

Mono minimal installation

Long ago you had to build your own Mono but now it is just about installing a small set of packages:

$ sudo apt-get install mono-runtime
$ sudo apt-get install libmono-corlib2.0-cil
$ sudo apt-get install libmono-system-net2.0-cil
$ sudo apt-get install libmono-system-data2.0-cil
$ sudo apt-get install libmono-system-web2.0-cil

This is all what a Plastic server needs to run.

Download the Plastic server zip installer

Next step is to download the Plastic server binaries. We always publish the binaries in zip format in order to ease installing without standard packages. And the Raspberry case is a perfect example.

I'll download version 5.4.16.671 and unzip it as follows:

$ pwd
/home/pi
$ mkdir plastic
$ cd plastic
$ wget http://www.plasticscm.com/download/downloadinstaller/5.4.16.671/plasticscm/linux_x86/serverzip?Flags=None -O server.zip
$ unzip server.zip

Configuring the server

Now the server binaries are ready, but there are a few more steps to complete: setup the correct config files.

First I'm going to configure the "remoting.conf" file, which is the one setting up the port where the server listens.

We include a "config_samples" directory in the zip with some of the configuration files required to run the server (normally all of these is done by the installer or the linux packages, but we're going the hard way today).

$ cd server/
$ ls config_samples/
db.conf loader.log.conf remoting.conf

Then I'll copy the remoting.conf that comes by default.

$ cp config_samples/remoting.conf .

Next I'll configure the db.conf: I'm going to use a SQLite backend so I'll use the following db.conf file:

$ cat db.conf
<DbConfig>
 <ProviderName>sqlite</ProviderName>
 <ConnectionString>Data Source={0};Synchronous=FULL;Journal Mode=WALL;Pooling=true</ConnectionString>
 <DatabasePath>/mnt/plasticdata</DatabasePath>
</DbConfig>

As you can see the databases will be on /mnt/plasticdata, which in my case is an external 64GB USB drive.

Next I'll configure the log:

$ cp config_samples/loader.log.conf .

And I'll edit it so the output goes to the console. All you have to do is to edit the end of the file as follows:

$ tail -n 5 loader.log.conf
 <root>
 <level value="WARN" />
 <appender-ref ref="ConsoleAppender" />
 </root>
</log4net>

And finally I'll create the following server.conf file:

$ cat server.conf
<ServerConfigData>
 <Language>en</Language>
 <WorkingMode>UPWorkingMode</WorkingMode>
</ServerConfigData>

Since I'm using "user-password" security mode, I'll create a user to be able to access my server:

$ mono umtool.exe createuser pablo mypassword

The last step is to copy a valid license file, you can request a Personal License or you can use an evaluation or commercial one (or alternatively you can configure a token file).

Starting up the server

We're ready to start our PlasticSCM server! Are we? Well, yes, now we can just start the server with the following command:

$ sudo ./plasticsd start

But we could tweak our configuration a little more in the name of our future comfort. You see, if we reboot our Raspberry Pi now, our server would not start automatically. Or if we do something that requires us to stop or reboot the server (change the database backend or the authentication mode, for example) we must remember the path where the plasticsd file is located. Chances are, if you're a (maybe not that) hardcore Linux user, you would expect it to run as simple as this:

$ sudo service plasticsd { start | stop | restart | status }

Let's configure that. First, we must edit the first lines of the plasticsd file to match the following:

#!/bin/bash
### BEGIN INIT INFO
# Provides: plasticsd
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: PlasticSCM server
# Description: Plasticd is the Plastic SCM Server provided by Codice Software S.L.
### END INIT INFO

The Required-Start and Required-Stop parameters indicate that Plastic SCM should start/stop only if the filesystem and the system logger are available (as you could imagine, Plastic would fail without a filesystem).

The values after Default-Start and Default-Stop parameters are customizable. You can change them to fit your needs:

  • The Default-Start values indicate when the script is going to start:
    • 2: when the system is configured as multiuser mode without network support (we could omit it because the Plastic server is useless without a network, but we'll keep it there).
    • 3 and 4: same as 2 but with network support.
    • 5: same as the previous values including graphic (X11) support.
  • The Default-Stop values indicate the moment when the script must stop:
    • 0: when the system is halting.
    • 1: when no other user than root is available (a kind of maintenance mode).
    • 6: when the system is going to reboot.

Now, we're ready to make a symlink of the plasticsd file to /etc/init.d:

$ sudo ln –s plasticsd /etc/init.d/plasticsd

And, finally:

$ sudo update-rc.d plasticsd defaults

Now it's time to start our Plastic SCM server from anywhere as a Linux service:

$ sudo service plasticsd start

And from another computer you can run an lrep to check the connectivity, now your server is up and running on Raspberry!

Closing

Well, obviously the Raspberry hardware is not what you'd use for a production machine, but we have some small teams using a Raspberry as tiny backup server :-)

In my case I find extremely interesting to run our own code on a different processor, especially now that Mac PPCs are no longer common and Solaris SPARCs even harder to find on real life (we fixed some endian-related bugs long ago thanks to an old SPARC iron that I used to have behind near to my table).

While you can't expect great performance, once the Plastic server caches a few changeset trees in memory (in fact the first one will be the slower) you can expect pretty decent response times. The IO ends up being the strongest limiting factor: I use a USB stick which isn't obviously the fastest thing.

Hope you enjoyed the post :-)

0 comentarios: