Sunday, September 28, 2014

Start Services on Boot in Rackspace

Rackspace provides Redhat servers. Suppose we are deploying a web application on a server. The web application uses many services - http service, search service(elasticsearch), caching service, database service(mysql, mongodb), etc .

There may be cases where would need to reboot the server. In such scenarios, the above listed services, when the server reboots, might not start. This is where the utility named chkconfig helps.
chkconfig --list
The above command lists the services which can be configured to start on boot-up. The first column lists the name of the service while the rest of the columns tell at which runlevel the service is started.

Runlevels control which services are automatically started by the system when the system starts in that runlevel. Here is the link that explains run level more explicitly. On a sidenote, to make the concept of a runlevel more clear, we can specify runlevel at the time of boot in the grub file. Runlevels are really helpful, when we want to enter the terminal and edit the messed up startup scripts which prevent normal system boot. This link will be helpful to understand my point.
Coming back to chkconfig, it is really easy to include services in chkconfig and specify the runlevels at which they will be started.
chkconfig --add SERVICENANE
Using the above command, we can add the service in the runlevels specified in the init script of that service. For example, the is the init-script of elasticsearch:
## /etc/init.d/elasticsearch


#
# elasticsearch 
#
# chkconfig:   2345 80 20
# description: Starts and stops a single elasticsearch 
#              instance on this system 
#

### BEGIN INIT INFO
# Provides: Elasticsearch
# Required-Start: $network $named
# Required-Stop: $network $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: This service manages the elasticsearch daemon
# Description: Elasticsearch is a very scalable, schema-free and 
#              high-performance search solution supporting multi-tenancy 
#              and near realtime search.
### END INIT INFO

The might be cases where the service is not recognized by the chkconfig even though it is located in /etc/init.d. This is because the above lines (see the above code) are not added in the script. Though these lines are commented, they are used by the chkconfig to recognize it as a service that can be added at boot. For example, I used Nginx to serve http requests. The nginx init script (/etc/init.d/nginx) did not have the above code block. This is what I added at the beginning of the file after #!/bin/bash to make it chkconfig friendly.
# 
# nginx         Service that starts and stops the http server
# chkconfig: 2345 95 05
# description: HTTP server
# processname: nginx
# config: /etc/nginx/conf/nginx.conf
# pid: /opt/nginx/logs/nginx.pid
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Short-Description: start and stop nginx server
# Description: HTTP Server
## END INIT INFO


Now, if I want to add a particular service to say, runlevel 2,3,4,5 - then, this is the command that I will execute:
chkconfig --level 2345 SERVICENAME on
You can figure out more use cases for chkconfig by viewing its manual.

Sunday, January 26, 2014

An Experience to Remember

Sitting with the bunch of students, I, being one of them, felt completely lost. I was oblivious of the coming lecture. Didn’t know who the professor was. The feeling of blankness was weird, considering the fact that I got decent grades. The benches, were surprisingly designed for only one student. One student per bench. I felt comfortable. Finally the teacher arrived. It was difficult to recognize his face. I hadn’t seen him before. So he started with some jokes, to which all the students were laughing except me. I was clueless. Anyways, the teacher told that since its the first day of the week, he won’t be teaching anything, but would be asking questions and hold discussions of what happened last week. Out of nowhere, he again, cracked some funny joke and all the students burst out laughing. Everyone seemed excited at the idea that they would be asked questions. This was the first time, I felt that I was completely out of ground over here. Totally unprepared, unaware of the subject, unrecognizable face of the teacher, all these things made me a bit scared.

So the round of questions began. He was asking randomly, allowing the students to raise their hand and answer them. Sometimes, he even pointed out a particular student and asked him a specific question. I felt frightened by this. I felt that he had noticed my fear, and was eagerly waiting to give me a chance to answer a  simple question. After listening to the bunch of questions, I suddenly realized, that the subject being discussed about here was Physics! Suddenly the professor pointed at me, and asked me a really easy question. I could feel it as easy, because all the students were eagerly looking at the teacher, so that even if he makes a single expression of approval to any one of them, they would blurt out the answer. I, completely listless, stared at him. He seemed disgusted by me and turned away leaving the question to be answered by someone else. I felt relieved that I was not punished, because by the look of his face, I felt like I had done the worst crime possible.

In the meanwhile, a friend of mine, on the front bench, turned to me and started pulling some joke on the teacher. In reply , I smiled and the professor caught hold of my sight. He got a perfect opportunity to lend me a harsh punishment. Rushing towards me with an evil smile that finally he found someone that he can spurt his anger on, he took my hand, grabbed me forward and started hitting me on the back, simultaneously pushing towards the door to throw me out of the class.

First thing that came to my mind while getting hit - that this is not me. I rarely go to classes unprepared. Even if I do, I am not so dumb to have forgotten the name and face of such a terrible teacher. I would surely remember him. I was pleased with my thoughts at that moment. I never thought so much before. Then, I suddenly realized that I am not in a school anymore. I got a decent job, a good life. So why am I present in the school, as a student? After thinking for some time, it dawned on me that I was in a dream. I felt surprised that I could be conscious in my dream too. This had never happened before. I thought that instead of being awed at the events, I should better try to handle them. I was being beaten mercilessly, but the teacher seemed to have just started. Suddenly I got a really amazing thought. Why don’t I make the most of this dream, do something that I wouldn’t have even dreamt about, try to fulfill all my dark fantasies (:evil smile:).

I don’t know how did it came there.but I suddenly grabbed the iron pipe and hit the teacher on his head. I took care  not to hit him too hard that he start bleeding but intense enough that he start screaming. Next, I ran from there as fast as I could with the pipe in hand. My class was on the third floor, and I wanted to reach the ground. I wanted to find some nice teachers on the way, if possible, and thank them for everything that they did for me. There were two three names that came to my mind. So hoping to find them while running, I reached the play ground. Sadly I wasn't able to find anyone. I didn't know why I was in a hurry, trying to do everything as fast as possible. Reaching the ground, I suddenly found my classmate whose presence really irked me. He was someone who pretended he knew everything but was a dumb ass in reality. I felt a surge of anger and excitement, and ran towards him with the pipe. On seeing me, he ran too. I stopped midway trying to catch my breath. I had never run so much before. He, standing a few paces away from me, was giggling at me. I felt angry again and resumed running. 

On the way, my sight caught hold of a beautiful computer science teacher who was talking to someone. She wore a glittering black and white dress, her head covered in a black dupatta. She was insanely cute, with her fair skin in perfect contrast with what she was wearing. I was her favorite student as I used to get really good marks in her subject. Then I thought suddenly, that this probably might be the only dream, in which I am perfectly aware of who I am. What should I possibly do. to make this dream the perfect dream ever? Finding my answer, I stopped running, forgot about that irking boy, dropped the pipe and started moving towards her. I was careful, that she doesn’t recognize someone rushing towards her. Finally, standing beside her, before she could see me, I tried to grab her, with a surprisingly strong force. She fell into my arms, and before I or she, could think of something, I kissed her. I felt my lips touching hers delicately and it felt like the most wonderful thing ever happening to me. I wouldn’t let go of her lips. I took care not to push myself too much to make her feel uncomfortable. I wanted her to have a memorable experience too. She resisted initially but gave away in few moments.

Accomplished almost everything that I had thought of, I opened my eyes to the dim reality.

Monday, January 13, 2014

A night traveling via Train

It’s been long since I have traveled in sleeper class.The platform near sleeper class is crowded. and the quality of the crowd is really depraved. It also depends on the quality of the train - if it is Rajdhani, everything looks good, but other lower level trains, all is pathetic. In terms of cleanliness in the compartment too,  Sleeper class comes below everything (not considering the General Compartment here). The coach vibrates a lot compared to an AC one, less no of lights,  no separate lights for reading,  no charging port. I brought a novel thinking that I would read,  but the intense vibrations,  the commotion created by the people,  the rhythmic but loud noise of  the running train,  all of this made it impossible for me do anything other than lying around I couldn't even listen to songs.

I don't know why one would like to travel in a train. I don’t find any valid reason except the fact that you get to see the variety of people over here. Variety in terms of caste, religion, language,  age,  sex,  the so called eccentric personalities (esp. the people who act as loudspeakers) There is one thing though which i like -  those are the children.  they seem to me the funniest beings capable of entertaining everyone around them without realising it. I am talking about the kids in the age group of 2-10. Kids, if too small, cry a lot,  and they are a nuisance when their parents are unable to make them not cry.  Apart from that,  one thing that I think I like in trains is -   sitting near the window in the daylight gazing at the unending greenery,  shining tracks in parallel,  the occasional sight of dogs or farmers with their animal companions on the field,  small huts in the midst of vast stretches of open fields, etc. But all of these tend to get boring after some time.  and monotonous.
This time, I had a couple sitting opposite to me,  hand in hand,  watching a movie on a laptop.  the girl seemed to be from Rajkot.  Rajkot people have a unique accent.  One can pick them out easily,  She was extremely talkative, but the rhythmic rajkoti accent of hers made her voice bearable,   Her lover seemed to be doing a pretty nice job of listening.  Also,  they were at the receiving end of eye popping glance of the elderly people sitting at the other end.  People in this country have a difficulty minding their own business.

On a side note, I , sometimes, wonder why so many couples are the followers of public display of affection.  What makes them curl hand in hand,  leading to them being the cynosure of all eyes.  why be the center of attention for no good reason?  Why not control your emotions or hormones or whatever it is, to the point where it actually makes sense to display it.

The worst part, my berth was the end of the coach. And it is winter time. I had two jackets on plus a blanket. The worst part was, the door of the train could not be latched. Due to this, the opened door in the middle of the chilly night on the running train, gave me intense chills. Unfortunately, I brought a thin blanket with me, thinking that having wore two jackets already, I won’t need anything else. The Result - I couldn’t sleep properly as I woke up frequently being on the receiving end the stream of chilly air from the opened door.


Overall, the experience was new and eccentric. But I ain’t sure whether I will try taking the Sleeper class the next time I am travelling via train.

Thursday, July 25, 2013

Title-less random talk + Introversion

I have an urge to write down the thoughts of mine, since quite a long time. I always desired to write whatever comes to my mind, but unfortunately, it went blank every time I sat down to write. Thankfully, this time around, there are some things lingering in my mind, that I want to jot it down. For now, the reasons to write these things down is to clear out my thoughts, be sure of what I want to do with my plan, maintain an account of my thoughts which I can go back to later.

When I read the blogs of others amateur writers trying out their literary skills, most of the time, it consists of some short story where they can pour out their imagination and showcase their creative aptitude. I, on the other hand, tend to write out about myself, my goals, my ambition, about the things I learnt along the way. I feel like, currently I might be lacking in the imaginary skills that is required of me. Nevertheless, I feel that writing the observations made to understand the mysteries of life is also useful. Still, someday, I would definitely try out my hand at writing short stories and try to experience the thrill of the process.

I am a programmer. I program to build features of a website and also solve technical problems that come along the way. I, always, am occupied with this strong feeling that there is more to me than to just being a common programmer. I want to do something that is completely different from what other people of my age would do. Most importantly, I don't want to be stuck on doing mundane job day in and day out. I want to do something challenging, intellectually absorbing, something that excites the very core of me. Perhaps this is the reason why I want to pursue Masters from a foreign university, because, somehow I feel that the research opportunities provided to me over there would be ample enough to placate my so-called over-ambitious needs. Even this urge and act of penning down my thoughts have stemmed from the thoughts of doing something different apart from work.

Meanwhile, effort is always undertaken to understand who I am, what I want and what would probably be the best conditions where I may perform to my utopian best. Recently I have been reading quite a number of posts related to understanding introverts. I, and the people around me, have always perceived me as a quiet and always-to-himself person. This was the reason why I am always fascinated to read more about introverts and how they come to fit in an out-going society because I feel myself as one having difficulties with communicating with the people who I am not closely associated with. But, reading these posts, I came to know, that the first thing for an introvert to feel happy about himself and contribute to the optimum level in a society, both in a direct and indirect manner, is to embrace his introversion. Introverts are good the way they are, its the job of the people around him to appreciate his nature rather than he, in order to fit himself in, try to be someone he is not. After reading all these and trying to apply the same in my day to day life. I am able to live more happily than before. Being more of a into-himself, and self-obsessed person. I feel being the same way every moment, is actually helping me understand myself in a better way. I am able to look through the foul and the best parts of my behavior. I am able to dissect different parts of me, try to understand their importance, their meaning, their paradoxes and know why they exist as a part of my life.

Here are the references to know more about introverts:


Wednesday, July 10, 2013

Improve Writing skills

I haven't written anything since a long time. I feel that I will lose the ability to pen down my thoughts in a decent manner, I rarely take time to write, even if it is something ridiculous. So this is the post that is totally irrelevant, topic-less and sheer time-pass, but for it this is a attempt, after quite a long time, to reinvest my time in writing.

Writing is a difficult skill, when you don't know the title of your article. Below are the topics on which I can possible attempt to write something that is worth reading

  1. Technical article: It can basically involve certain pointers on how to solve a particular problem and the approach taken to do the same
  2. Writing Reviews:  I always make time to read something or the other during the course of my day. If I am able to write down main points of the things that I read, and then at the end of it, write something, connect the gaps, it will ultimately, not only help in making me understand the topic in its totality but also I will be able to make a reference point.
  3. Exploring creative potential: This is something, that is quite hard to me to write on presently. Frankly speaking, I haven't tried at writing creative stuff at all. But I think its worth the time, because by doing this, I will be able to exploit a possibly unknown aspect my life

Sunday, April 14, 2013

Installing packages from AUR - Archlinux

I wanted to install yaourt in my system which has archlinux installed. Yaourt is a nice tool when you want to search through the packages that are not present in the official repository. It is not available in the official repository, so it cannot be installed using pacman. Also the documentation of AUR provides a nice step by step instructions on how to install packages from AUR. To search for package, visit this link

Here are the list of steps that should be followed while installing packages from AUR.

  • Download the tarball of the PKGBUILD. Extract the tarball when downloading by running $ tar zxvf package_name. The storage location of the download will be folder: package_name
  • Download the actual package, The download link of the same will be given on the same page as above. Extract the tarball of the downloaded package. The storage location of the download will be folder: package_namev1
  • Now copy the PKGBUILD file downloaded in the first page to the folder the contains the source package. cp package_name/PKGBUILD package_namev1/
  • Now go the source package folder and run the commands:
    • $ makepkg(This will create a file named package_namev1.tar.gz, which can directly be installed with pacman)
    • $ sudo pacman -U package_namev1.tar.gz

The reason I have listed the above steps even though the AUR page has provided the step by step instructions, is because some of the steps like copying the PKGBUILD to the package source location and then running makepkg is not specified clearly.

Friday, April 5, 2013

The act of questioning

Here are the few brief points after discussion with one of the friend of mine. The topic was on what should be the right attitude when you are looking at things, when you are observing things, and when you are making certain conclusions out of it. I will get into the details of the discussion some other time, but below are few important points that came out of our talk:


1. Know the how and why of things before arriving at any conclusion
2. Always be curious to know why a certain thing happened instead of brooding over the results
3. The act of educating ourselves should result in us questioning every norm and every idea that is being followed.