++ed by:

2 non-PAUSE users.

Andrew Johnson
and 1 contributors


MP3IndexerService - Helios service to index MP3s to a database table


 # start the service daemon
 helios.pl MP3IndexerService
 # submit jobs using the included cmd line utility
 locate .mp3|mp3submit4index.pl


This is a sample application to demonstrate some of the features of the Helios distributed job processing system and how to write services for it.


In the sql/ directory are two files: schema.sql and config.sql.

The schema.sql file contains the SQL to create the MP3_INDEX_TB table that MP3IndexerService will write all of its data to.

The config.sql file contains the SQL to create the configuration parameters MP3IndexerService needs to connect to the database that contains the MP3_INDEX_TB. Edit it appropriately for your system and issue a command like the following:

 mysql -D helios_db -u helios -p < config.sql

to create the configuration needed for MP3IndexerService to connect to its database.

Once that is done, you should be able to start the service with helios.pl:

 helios.pl MP3IndexerService

and then submit jobs to the service using the included mp3submit4index.pl program:

 find / -name "*\.mp3" -print | mp3submit4index.pl

Happy MP3 indexing!


As always in Helios applications, the run() method is the main subroutine in the application. It receives a job to process in the form of a Helios::Job object, it calls the subroutines or methods necessary to do the job processing, then it marks the job as successful or failed and returns.

This particular run() method:

  • checks to make sure it can read the file it was given (and throws a Helios::Error::InvalidArg exception if it can't)

  • calls a method to parse the ID3 tags and other info of the MP3 file

  • calls a method to update the index table in the database with the new MP3 info

  • marks the job as successful unless any kind of exception was thrown. If any kind of exception was thrown (either by throwing a Helios::Error exception, calling die(), or some other method), run() will log the error in the Helios log and mark the job as failed.

Though Helios applications can become very complex, every service class follows this same basic, simple pattern. This makes it easy in most cases to write Helios applications.



Given a filename, parseMP3info() returns an MP3::Info object with information on the given MP3 file.

updateDb($filename, $mp3info_object)

Given the MP3 file and the MP3::Info object with that file's info, updateDb() adds the information on that MP3 to the database table, either through an UPDATE (if the filename is already in the table) or an INSERT (if the filename isn't already there).

Note that this method uses the Helios::Service->dbConnect() method to connect to the database, and uses database connection information set in the Helios configuration subsystem. All the method need do is call the getConfig() method, and it has a hash with all of the configuration parameters for the current application running on the current host.


Helios, mp3submit4index.pl, MP3::Info


Andrew Johnson, <lajandy at cpan dotorg>


Copyright (C) 2012 by Andrew Johnson

This library is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.