nodejs and ports

20. April 2013 Kommentare ausgeschaltet

During my development with nodejs I stumbled over a very annoying problem. The server started, but I was not able to connect to it on the specified port. Furthermore, after a restart of the server, it reported an “EADDRINUSE Address already in use” failure. On further investigations, it looked like that for each time the server started with a port it created a new directory in the application root.

It took me about one hour, to figure out, that changing the port to a value outside the “root range” (up to 1024 on Linux, but it looks like the same is true for e.g. 3000), everything was working normal. Lesson learned ;-)

KategorienCommon Tags:

Open Source Projects and their Teams

12. April 2013 Kommentare ausgeschaltet

In any Open Source Project you will find the same players like in most (say all)  teams.

I have just participated in a Leadership Training and got introduced to the roles in teams. At the same time I started to program in an open source team to implement a small application. Since this is not my first involvement in an open source team, I thought, it would be quite interesting to map the “official company environment” onto the open source world. Not really to my surprise I found out, that the company environment is quite similar to the open source environment.

There are some differences in open source teams and teams in a company (eg. there is usually no money involved at the beginning of an open source project), but there are also a lot of common things. I was involved in quite some OSS projects and all projects which are successful there is a strong leader (see maven. There are, of course, other open source projects, which totally belong to the community (see Debian, but there are no commercial interests and also all decisions in these projects do take quite a long time (see: http://lxer.com/module/forums/t/29437/).

IMHO this is also true for companies. With strong I mean somebody able to sell his vision and got people interested in
the technology behind. Nowadays technology is mostly something new and interesting like eg nodejs or nosql. In a company environment you do not need a nice technology to gather people around you, but to gather bright people you do need it as well.

KategorienCommon Tags:

nodejs version 0.8.x instead of 0.10 on ArchLinux

18. März 2013 Kommentare ausgeschaltet

Right now, I am developing a node application. Since we are using 0.8 and on ArchLinux 0.10 is installed if figured to install nave and n. This is all working fine, as long as I am not using a binary npm package, like node-expat. To install this, I needed to remove the node_modules folder after the change of the node version, and furthermore I needed to define the python-version. The install of packages is then possible with the following command:


npm install --python=/usr/bin/python2

KategorienCommon, Linux Tags:

Sympa Mailinglist Server on CentOS 6.4 using PostgreSQL

17. März 2013 Kommentare ausgeschaltet

To install Sympa on a CentOS 6.4 machine is not as easy as one would expect. I found this entry in one of the mailing lists, and I have to admit, it works like a charm ;-)

So, here once again, for reference:


cd /etc/yum.repos.d
wget http://sympa-ja.org/download/rhel/6/sympa-ja.org.rhel6.repo

cd /var/tmp
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -i epel-release-6-8.noarch.rpm

yum install sympa-httpd

Review /usr/share/doc/sympa-6.1.17/README.RPM-install

After this, I needed to install a RDBMS, and since I do prefer PostgreSQL I installed it (using the tutorial from here) via:


yum install postgresql postgresql-server postgresql-contrib postgresql-devel

# Initialize database directory
service postgresql init

# Start service
service postgresql start

# create sympa db
su postgres
>createdb sympa
>psql sympa
>>CREATE ROLE sympa WITH SUPERUSER LOGIN PASSWORD 'sympa';
>>\q
>exit

Furthermore, I adopted the file pg_hba.conf:


#host all all 127.0.0.1/32 ident
host all all 127.0.0.1/32 md5
#host all all ::1/128 ident
host all all ::1/128 md5

To check, if the connection is working, try:


psql -h localhost -U sympa sympa

Also the perl package DBI:Pg is needed for the connection of sympa to postgres.


yum install perl-DBD-Pg

After all these preparations, we are going to install sympa.


sympa_wizard.pl

Note, that it is possible to change the made settings in the /etc/sympa/sympa.conf file. Since we are using PostgreSQL we do have to adopt the setting db_port in this file to 5432.

To create the DB correctly (basically, the DB is already created above), I had to comment out the database creation in the file /usr/share/sympa/bin/create_db.Pg:


--CREATE DATABASE sympa;

Unfortunately the script sympa.pl --create_db was not working correctly for Postgresql, and therefor I tried to run the DB creation script manually:


psql -h localhost -U sympa sympa
>\i /usr/share/sympa/bin/create_db.Pg
>\q

After this, everything seemed to be alright ;-) And another thing, CentOS seems to be pretty restrictive, so please stop iptables or adopt the settings, otherwise it is not possible to connect to the server from the outside.

Not everything is alright here, I needed to change some of the premissions of the fcgi-Scripts in /usr/libexec/sympa as well as the description for the file /etc/sympa/sympa.conf. Furthermore centOs is making heavy use of SELinux, therefor some additional settings need to get applied:


setsebool -P httpd_can_sendmail 1

Since I am using this only in a virtual box, I disabled SELinux completely, therefor the above statement is not necessary at all anymore.

After all this, sympa is still running in maintenance mode, because of several permission restrictions of sympa (which are fine for productions environments, but for a development environment these are just nasty). Therefor I followed this guide (specifically: run apache as the user sympa).

Btw, if you wander, why the heck CentOS is now on my list of OSes, this is mainly to work with the same environment like my hoster and on ArchLinux I did have a lot of trouble to install Sympa as well ;-( I am working with Sympa now in a VBox, so that it does not disturb my normal system usage.

KategorienCommon, Linux Tags:

Installl Logitech Unified Receiver

2. November 2012 Kommentare ausgeschaltet

I just bought some new Input devices (the same I already use at work with Win7), a Performance MX Mouse and a K350 Keyboard from Logitech. Both devices use the Unified Receiver from Logitech. I used the Unified Receiver of the Keyboard initially and after starting the Laptop with the Receiver connected and the Keyboard and the Mouse turned on I did not get a connection from the mouse.

After fiddling around I stumbled across the following article, which described exactly what I had to do. Thanks to the Archlinux community another device is ready to be used ;-)

https://wiki.archlinux.org/index.php/Logitech_Unifying_Receiver

But there is more to come, because I want to use all the nice little buttons on the mouse and on the Keyboard as well, so lets see how this is going to work out ;-)

KategorienCommon Tags:

tonidoplug 2 and Western Digital Blue Scorpio 1TB

30. August 2012 Kommentare ausgeschaltet

I just bought a 2,5″ Blue Scorpio from Western Digital. Basically I thought that it is 2,5″ and should fit into my Tonido Plug 2. Unfortunately this is only true with some minor “Hardware modifications” on the Tonido Plug. I had to use a Scissor to adopt the Tonido Plug to the HDD and also the cover does not fit anymore. Anyway, the drive seems to work and I am now in the process to install ArchLinux ARM on this new device and boot permanently from it.
More on this one in a later post.

KategorienCommon Tags:

Tonido Plug 2 – Wlan

12. August 2012 5 Kommentare

I have the problem, that after a certain amount of time, the wlan is not responding anymore on my Tonido Plug 2. I have now updated the Power Management on the device to “off” using the following commands:


sudo iwconfig mlan0 power off

Hope, that this helps ;-)

KategorienCommon Tags:

SparkleShare Dashboard

30. Juli 2012 Kommentare ausgeschaltet

Today I wanted to install SparkleShare-Dashboard on my Linux Laptop. I was pretty glad, since it is a nodejs application and the target plattform, where I would like to install this application finally, will be a nodejs system (ArchLinux ARM) as well.

To install SparkleShare Dashboard on the latest nodejs-Version (v0.8.4) I had to adopt the Git-Child-Process creation in the backend/git.js-Module. For the full working version, please see .

There is also a little “difficulty” and probably a miss-understanding in the community of how to create a “SparkleShare-Git-Repository”. I have done it, therefore please find a step-by-step guide:


mkdir -p /home/USERNAME/sparkle/public.git
cd /home/USERNAME/sparkle/public.git
git init --bare
mkdir /home/USERNAME/tmp
cd /tmp
git clone file:///home/USERNAME/sparkle/public.git
cd /tmp/public
touch README.txt
git add README.txt
git commit -m "Initial commit"
git push origin master
cd ..
rm /tmp/public -rf

This should be it, you do have an initial commit in the repository, and therefor SparkleShare can attach the id to the repository (the id is the SHA1-id of the first commit in the repository).

KategorienArch Linux, Common, Linux Tags:

ArchLinux on a TonidoPlug2 with WLAN

29. Juli 2012 Kommentare ausgeschaltet

Hello,

for my current vacation (my wife is going to look Olympic Games via TV the whole time) I decided to do me a favor and bought a TonidoPlug2. Since I am pretty much into ArchLinux, I decided to put ArchLinux on this device as well (see ArchLinux ARM). I used the Installation description on the above site without any problems, the way I did it, it went quite smooth. The difference was, that I did install the whole distribution on an USB-Stick before the device even arrived using my ArchLinux Laptop. Very nice ;-)

Now I am in the process of finish the Installation on the device (following some advice from binarybitme and this went pretty smooth as well. The tipp with the haveged is pretty useful for the current upgrade of pacman, which requires some entropy for the pacman-key --init command.

Furthermore I decided to use WLAN on this device (hey, thats why I decided to buy this one). Therefor I found one interesting forum entry which helped a lot ;-) In the current version of Arch Linux, the firmware is beneath /usr/lib and not under /lib, like described in the post. Then I installed netcfg and configured /etc/rc.conf and /etc/network.d/w-int-static (wireless device) as well as the /etc/conf.d/netcfg (without this one, netcfg can work, as long as rc.conf is configured correctly). For the whole wlan stuff to work (depending on your used security key) I had to install wpa_supplicant.

rc.conf:

MODULES=(mwifiex_sdio)

HOSTNAME="triton"

# Default network config (fallback, just to get access to the device, if
# wlan configs fail)
interface=eth0
address=192.168.1.25
netmask=255.255.255.0
gateway=

DAEMONS=(... network net-profiles ...)

/etc/network.d/w-int-static

CONNECTION='wireless'
DESCRIPTION='A wpa_supplicant configuration based wireless connection'
INTERFACE='mlan0'
SECURITY='wpa-config'
WPA_CONF='/etc/wpa_supplicant/wpa_supplicant.conf'
IP='static'
ADDR='192.168.0.25'
#ROUTES=('default via 192.168.0.1')
GATEWAY='192.168.0.1'
DNS=('192.168.0.1')
# Uncomment this if your ssid is hidden
#HIDDEN=yes

/etc/conf.d/netcfg

NETWORKS=(w-int-static)
# Specify the name of your wired interface for net-auto-wired
WIRED_INTERFACE="eth0"
# Specify the name of your wireless interface for net-auto-wireless
WIRELESS_INTERFACE="mlan0"

I am not going to show my wpa_supplicant-settings, but these were fairly easy and could already be tested on the laptop.

KategorienCommon Tags:

dbUnit in a Spring Environment with MSSQL

20. Oktober 2011 Kommentare ausgeschaltet

Today I needed to export and import some data from a database for testing purposes. I do knew dbUnit already and this seemed to be the tool of choice. I stumbled about a couple of problems, because another example of the usage of dbUnit with the Spring Framework was using Oracle and furthermore the FlatXmlDataSet. I wanted to use the XmlDataSet, because this seems to be easier to maintain manually.

In the following I will try to show, how to integrate dbUnit into the project. First of all, I needed to put the Maven Plugin into place:

<dependencies>
        <dependency>
            <groupId>org.dbunit</groupId>
            <artifactId>dbunit</artifactId>
            <version>2.4.8</version>
            <scope>test</scope>
        </dependency>
...
</dependencies>
...
<build>
   <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>dbunit-maven-plugin</artifactId>
                <version>1.0-beta-3</version>
                <!--jar file that has the jdbc driver -->
                <dependencies>
                    <dependency>
                        <groupId>net.sourceforge.jtds</groupId>
                        <artifactId>jtds</artifactId>
                        <version>${jtds.version}</version>
                    </dependency>
                </dependencies>

                <configuration>
                    <driver>${database.driver.classname}</driver>
                    <url>${database.url}</url>
                    <username>${database.user}</username>
                    <password>${database.password}</password>
                    <dataTypeFactoryName>org.dbunit.ext.mssql.MsSqlDataTypeFactory</dataTypeFactoryName>
                    <ordered>true</ordered>
                </configuration>
            </plugin>
...
</plugins>
</build>

After this I was able to call mvn dbunit:export, which gave me an export of the current datastructure inside the database. It will generate a file target/dbunit/export.xml, which could then be used in the TestCases (we are using JUnit).

The TestCases are now looking something like this:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:/META-INF/spring/testAC.xml"})
public class ServiceTest {
...
	@Autowired
	private DataSource dataSource;

Here we are autowiring the dataSource from the Application Context, this is needed to extract all necessary information for the database connection of dbUnit.

	// the following methods do make sure, that the database is setup correctly with
	// dbUnit
	private IDatabaseConnection getConnection() throws Exception {
    	// get connection
        Connection con = dataSource.getConnection();
        DatabaseMetaData databaseMetaData = con.getMetaData();
        IDatabaseConnection connection = new DatabaseConnection(con);
        DatabaseConfig config = connection.getConfig();
        config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new MsSqlDataTypeFactory());
        return connection;
	}

Here we are making sure, that the connection is setup correctly and that the right DataTypeFactory is used. This should be the same factory as used in the pom.xml (see above).

	private IDataSet getDataSet() throws IOException, DataSetException {
		File file = new File("src/test/resources/dbexport.xml");
		assertTrue(file.exists());
		Reader reader = new FileReader(file);
		return new XmlDataSet(reader);
	}

Fetching the dataset from a file and use it in the DatabaseOperation of dbUnit.

	@Test
	@Transactional
	public void testDelete() throws Exception {
        DatabaseOperation.CLEAN_INSERT.execute(getConnection(), getDataSet());
		EntityVersionId id = new VersionId("9a5a8eb1f02b4e06ba9117a771f2b69c", 2L);
		Entity entity = this.entityService.find(id);
		assertNotNull(entity);
		this.entityService.delete(id);
	}

Please note, that we are using a special EntityVersionId, which is part of our Framework and contains two values. This is a combined ID. The usual ID is an UUID (String) and a “version” of type long. I guess, you will most probably not use something like this in your project.

Thats it, now everything works like expected ;-)

KategorienJava, Projects Tags: