If you background a bash or shell process, how do you determine if it has finished? Since inter process communication is not possible using shell scripts, people often refer to while loops or other polling mechanisms to determine if some process has stopped.

However, the one player that knows best if a process has finished is the process itself. So if only this process could tell the parent or other process about this...

The solution is using a FIFO or 'pipe'. A listener process reads the pipe and executes a command for every message received through this pipe. This was already build-in into PPSS. However, PPSS had this dirty while loop that polls every x seconds to determine if there are still running workers. If not, PPSS finishes itself.

However, while loops and polling mechanisms are evil, dirty and bad. The nicest solution is to make PPSS fully asynchronous. To achieve this, every job must tell PPSS that is has finished. PPSS already has this listening process that listens to the pipe for commands. If this channel is used by workers to communicate that a worker is finished, PPSS will know when all workers are finished.

This makes PPSS a lot faster and responsive.

Laptop or netbook as router?
September 20, 2009 | categories: Networking | View Comments

If you want a router for distribution of internet to your computers at home, there are several options.

  • buy some embedded device from Linksys, Draytek, Asus, 3com, ZyXtel or netgear

This type of hardware is cheap, economical, and gets you up and running in a few minutes. The downside is that you can't do much else with these things. Yes, there are many custom firmwares, which allow you more freedom, but the hardware is often the limiting factor.

  • convert a regular PC into a router

If you want more than just routing, building your own router using a(n) (old) PC is the preferred course of action. The downside is that a PC often uses more 'juice' than an embedded device.

However, those new Atom-based PC's may be a very nice option. Just add a second network card, though an USB-port or a low profile PCI card and you have something far more flexible than an embedded router.

  • convert a laptop into a router

It sounds a bit strange and silly at first to use a laptop as a router, but it makes sense when you think of it.

  1. It is economical in terms of power usage
  2. It has a build-in UPS called a 'battery'
  3. It has a build-in screen and keyboard

All these things are an advantage regarding option 2.

Nowadays you can have a netbook for only 300 euros. It is more expensive than an embedded device, but almost as economical and provides much more performance and flexibility.

I've been running an old laptop as a router for 6 months without problems. Unfortunately, the disk died due to old age, but that can happen to any computer. I'm now running an old mac mini intel machine as a router.

In short:

  1. Buy whatever you fucking want.

  2. Turn the fucking thing off when you're not using it.

Long:

People are spending a lot of time building an energy efficient home computer, that can act as an HTPC, NAS, or whatever. It must consume as little power as possible, because it it will be on 24/7.

Why the fuck do you want to leave a system on 24/7 at home?

Unless you're unemployed you will be at work most of the time. And during that time, this machine is doing absolutely nothing.

There may only be one system that stays on 24/7 and that is your router, either some embedded router thingy or something based on a low-power PC, but that's about it. Turn every thing else off.

A machine that does 200 Watt idle that is only turned on when necessary will be more energy efficient than your specially build 40 watt NAS or whatever it is that is running 24/7. Nothing can beat a system that is turned off.

If you need a system, just use wake-on-lan or WOL to turn the damn thing on. It will be ready in about 2 or 3 minutes and then you can do whatever you want.

Fine if you leave a system on that is downloading some stuff during the night or day, but after the download has finished, turn the damn thing off.

If you're honest with yourself and really think about it, there is no need to keep a system on for 24/7. I know you may come up with excuses, but remember that you still can use your router for that.

By the way, if you're searching for a really energy efficient computer, buy a Mac Mini. Although quite expensive if you ask me, the're doing 30 watt in idle and almost nothing when sleeping. And if a mac is asleep, it can be woken with WOL and is up in seconds. They make an excelent download server.

[EDIT]

There is also the option of S3 or S4 under Linux: suspend to ram or disk. However, your mileage may vary. If it works for you your system will be down and up in seconds. However, my experience is that it very much depends on your hardware if this will work. My Highpoint cards do not seem to like it, my array does not awake and the screen of the system stays blank.

If it works, it is a faster solution than just to turn the system off and on with WOL. My experience is that is seems not that robust.

If you have some DVD's that you want to convert to your iPhone or iPod touch, there is already a nice solution called 'Handbrake'.

However, if you want to convert multiple DVD's and don't want to spend time manually adding each movie or episode to the queue, I might have some solution for you. I've written a script that uses HandBrakeCLI, the command-line version of Handbrake. This script is called "dvd2iphone" and can be downloaded here.

This script uses the VIDEO_TS folder or even the ISO image as input, and then processes all movies or episodes that are found, which are automatically named.

To be able to use this script, you need the command-line (CLI) version of Handbrake, which can be found here. Place this binary on your system and place the dvd2iphone script in the same directory.

Usage:

./dvd2iphone.sh (INPUT)

for example:

./dvd2iphone.sh /cdrom/VIDEO_TS

or

./dvd2iphone.sh casablanca.iso

This script can only process a single VIDEO_TS folder or single ISO at a time. However, you can create a text file containing a list of to-be-processed files and use PPSS on this list, in combination with the dvd2iphone script to automatically process all the DVD's.

Warning; you might want to edit the HandBrake command in the script to select the correct audio track and to add subtitles.

Please note that Handbrake can only use up to four cores to encode a single movie. If you have more then four cores available, it may be worthwile to run two instances of Handbrake simultaneously. PPSS is ideal for such a setup. Since my Core 7i 920 emulates 8 logical cores, I can encode two regular DVD's to the iPhone format at a framerate of arount 100 fps, for each DVD, which is 200 fps combined!

I will also create another version of this script that will allow you to transcode your DVD's to mp4 format at the same resolution. This allows you to reduce the size of your video collection on disk considerably, without loss of quality.

Although Handbrake is available for Windows, you have to figure out yourself how to run a Bash script under Windows.

If you build a NAS with many drives, it may be of interest to you which drives get hot and where they are located in the chassis. My Norco 4020 case has twenty drives in RAID 6, plus two operating system drives in RAID 1. I wrote a script that shows me the temperature of each drive, positioned in such a way that it represents the actual physical location of the drive in the chassis:

 -- 30 -- | -- 27 --
 | 26 | 27 | 28 | 25 |
 | 30 | 32 | 30 | 29 |
 | 31 | 33 | 33 | 29 |
 | 33 | 32 | 35 | 30 |
 | 32 | 34 | 35 | 31 |

In this example, you can determine that the top drives seem to stay the coolest. The center and lower drives get hotter.

If you want to use this script, you will have to change it for your own specific setup. You can get it here.

This visual representation would also be nice to identify which drive has failed and where it is located in the chassis.

20 DISK 18 TERRABYTE NAS

Just for fun, I've build myself an 18 TB NAS based on Debian Linux, software RAID, 20 disks and a Norco 4020 case.

Projects

Contact

Donate

If you find PPSS, WFS or LFS, usefull, consider a donation.

Categories

Archives