View on
Apocalypse > POE-Devel-ProcAlike-0.02 > POE::Devel::ProcAlike



Annotate this POD

View/Report Bugs
Module Version: 0.02   Source  


POE::Devel::ProcAlike - Exposing the guts of POE via FUSE


        use strict; use warnings;
        use POE::Devel::ProcAlike;
        use POE;

        # let it do the work!

        # create our own "fake" session
                'inline_states' => {
                        '_start'        => sub {
                                $_[KERNEL]->alias_set( 'foo' );
                                $_[KERNEL]->yield( 'timer' );
                        'timer'         => sub {
                                $_[KERNEL]->delay_set( 'timer' => 60 );
                'heap'          => {
                        'fakedata'      => 1,
                        'oomph'         => 'haha',

        # run the kernel!


Using this module will let you expose the guts of a running POE program to the filesystem via FUSE. This also includes a lot of debugging information about the running perl process :)


Really, all you have to do is load the module and call it's spawn() method:

        use POE::Devel::ProcAlike;
        POE::Devel::ProcAlike->spawn( ... );

This method will return failure on errors or return success. Normally you don't need to pass any arguments to it, but if you want to do zany things, you can! Note: the spawn() method will construct a singleton.

This constructor accepts either a hashref or a hash, valid options are:


This is a hashref of options to pass to the underlying FUSE component, POE::Component::Fuse's spawn() method. Useful to change the default mountpoint, for example. Setting the mountpoint is a MUST if you have multiple scripts running and want to use this.

The default fuseopts is to enable: umount, mkdir, rmdir, and mountpoint of "/tmp/poefuse_$$". You cannot override those options: alias, vfilesys, and session.

The default is: undef


This is a Filesys::Virtual::Async subclass object you can provide to expose your own data in the filesystem. It will be mounted under /misc in the directory.

The default is: undef


There is only a few commands you can use, because this module does nothing except export the data to the filesystem.

This module uses a static alias: "poe-devel-procalike" so you can always interact with it anytime it is loaded.


Tells this module to shut down the underlying FUSE session and terminate itself.

        $_[KERNEL]->post( 'poe-devel-procalike', 'shutdown' );


( ONLY for PoCo module authors! )

Registers your Filesys::Virtual::Async subclass with ProcAlike so you can expose your data in the filesystem.

Note: You MUST call() this event so ProcAlike will get the proper caller() info to determine mountpath. Furthermore, ProcAlike only allows one registration per module!

        $_[KERNEL]->call( 'poe-devel-procalike', 'register', $myfsv );


( ONLY for PoCo module authors! )

Removes your registered object from the filesystem.

Note: You MUST call() this event so ProcAlike will get the proper caller() info to determine mountpath.

        $_[KERNEL]->call( 'poe-devel-procalike', 'unregister' );

Notes for PoCo module authors

You can expose your own data in any format you want! The way to do this is to create your own Filesys::Virtual::Async object and give it to ProcAlike. Here's how I would do the logic:

        my $ses = $_[KERNEL]->alias_resolve( 'poe-devel-procalike' );
        if ( $ses ) {
                require My::FsV; # a subclass of Filesys::Virtual::Async
                my $fsv = My::FsV->new( ... );
                if ( ! $_[KERNEL]->call( $ses, 'register', $fsv ) ) {
                        warn "unable to register!";

Keep in mind that the alias is static, and you should be executing this code in the "preferred" package. What I mean by this is that ProcAlike will take the info from caller() and determine the mountpoint from it. Here's an example:

        POE::Component::SimpleHTTP does a register, it will be mounted in:

        My::Module::SubClass does a register, it will be mounted in:

Furthermore, ProcAlike only allows each package to register once, so you have to figure out how to create a singleton and use that if your PoCo has been spawned N times. The reasoning behind this is to have a "uniform" filesystem that would be valid across multiple invocations. If we allowed module authors to register any name, then we would end up with possible collisions and wacky schemes like "$pkg$ses->ID" as the name...

Also, here's a tip: you don't have to implement the entire Filesys::Virtual::Async API because FUSE doesn't use them all! The ones you would have to do is: rmtree, scandir, move, copy, load, readdir, rmdir, mkdir, rename, mknod, unlink, chmod, truncate, chown, utime, stat, write, open. To save even more time, you can subclass the Filesys::Virtual::Async::inMemory module and set readonly to true. Then you would have to subclass only those methods: readdir, stat, open.









You can find documentation for this module with the perldoc command.

    perldoc POE::Devel::ProcAlike



Please report any bugs or feature requests to bug-poe-devel-procalike at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


Apocalypse <>

Props goes to xantus who got me motivated to write this :)


Copyright 2009 by Apocalypse

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: