Monday, November 30, 2009

Adding our own Linux startup scripts

Do we need to start something when Linux system starts?
Its not a service.... But I need to run this command when system starts....

Yes here is a small part which astonished me as I have not learnt this for years and missed it when I need....

Let us take a sample case: We might need to start a SVN daemon on the system.
#svnserve -d /srv/repositories

We need to run the above command on every start-up autiomatically. So we don't need to start this daemon manually.

Simple way is add this along with other startup scripts. Find which runlevel the system runs normally.

[root@sf03 ~]# runlevel
N 3
[root@sf03 ~]#

Our server runs in run-level 3 so lets take that as an example.
The server runs on Fedora Linux 10

The startup scripts for run-level 3 resides in the directory /etc/rc.d/rc3.d/
The scripts for run-level 5 will be at /etc/rc.d/5.d/

The directory contains shell scripts that runs on the ascending order on by one.

The last script that runs is S99local

Which has the content similar to this.
[root@sf03 ~]# cat /etc/rc.d/rc3.d/S99local
#!/bin/sh

#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
[root@sf03 ~]#


Use the vi editor and add the startup command we need to add to this.

Example:

[root@sf03 ~]# cat /etc/rc.d/rc3.d/S99local
#!/bin/sh

#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.


touch /var/lock/subsys/local

# Start SVN Server at startup


svnserve -d /srv/repositories


[root@sf03 ~]#

Restart the server and check the script.

The Canonical Data Model

We have used canonical Data Model(http://www.eaipatterns.com/CanonicalDataModel.html) pattern for my client, Which minimise the dependencies from any integration application, which may use data format.

I love the pattern of creating canonical schema since, you will have a single entity through out the Enterprise
Example, An Order, You will be having a single XML schema defined, which talks every thing about order w.r.t to the company. Billing System in the organisation is interested in knowing the customer information, financial information from order to execute its business process. Inventory system is interested in the know the item information and number of items from order, to check for availability and so on. All these details can be get from a single Order canonical schema
Designing the Canonical schema Since BizTalk and other EAI tools work well with XML. The schema is an XML schema. it contains a two parts Header and Body.
The Header will have all the information about the business document (eg order). We at EMI, call this as enterprise header.

  1. Subject - Represent the action of the document or the represent the business document (Example Create.Order, Update.Order or Highvalue.Order
  2. Version - Document version keeps changing when you add/modify/delete element or attribute in the XML Schema
  3. Source system - Which system provides data for the canonic0
  4. Unique ID - To identify the Message
  5. Batch - you can add the batch information, if you are handling messages in batching

Well, What more, Add as much as information that might be interested w.r.t to your organisation. for example unique document number base on the source system. The Enterprise header should be same through out all your canonical schema. There will be one Enterprise Header through out the organisation

The Body part will contain the common business document (Say Order). Some Companies have a seperate department/team, which control what they look like. if you are lucky to have this department already in place, then your canonical schema body part is ready. or else you should define itSome good ways to identify the what should go into canoncal schema. Identify the information for you schema from source systems(Note : you may have more than one system provide the same business document). and cosolidate the structure. Easier one is the Master data. Identify the Master Data Management system in your enterprise. you can quickly create lot of canonical schema (Ex customer, employee, product etc)Follow International Standards, you can refer EDI Standards to create your body of your canonic. (Give meaning full name in your canonics)

Always populate the header only in the Middleware and remove the header before sending to target system. Since most of the target system expects their own format

So whats the Advantage
01. Transformation is Simple.
02. Help Developers the Business entities easily
03. Adding new subscriber will take lesser time to commission
04. Meaning full names in the Schema helps to align IT with the Business

Keep the php-pear up-to-date

PHP has evolved a lot and when we need add-on libraries, we opt for PEAR packages or PECL extentions to add more libraries that resolves our purpose.

Recently in one of our servers CEntOS 5.2, we were about to install phpUnits to run unit tests in it.

Unfortunately phpUnit was not installed on it.

The website gave the following options to install.

pear channel-discover pear.phpunit.de


and

pear install phpunit/PHPUnit


But the installation failed........ Oops it was odd to understand why?

The real cause was the pear module has not been upgraded to latest version the the new standard packages were not installed with this.

It would be better to do
pear upgrade pear
before we start any pear installations. Keep the pear up-to-date to make it work with latest library packages.