Skip Menu |

This queue is for tickets about the Smolder CPAN distribution.

Report information
The Basics
Id: 52973
Status: open
Priority: 0/
Queue: Smolder

People
Owner: Nobody in particular
Requestors: MARKSTOS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.51
Fixed in: (no value)



Subject: wish: improved diagnostic for running "smolderctl start"
I tried running "smolderctl start" and got this: ### Base class package "Server::Control::Simple" is empty. (Perhaps you need to 'use' the module which defines that package first.) at /home/mark/src/my_smolder/lib/perl5/Smolder/Server/Control.pm line 2 BEGIN failed--compilation aborted at /home/mark/src/my_smolder/lib/perl5/Smolder/Server/Control.pm line 2. Compilation failed in require at /home/mark/src/my_smolder/bin/smolderctl line 6. BEGIN failed--compilation aborted at /home/mark/src/my_smolder/bin/smolderctl line 6. ### However, using the same "PERL5LIB" ./bin/smolder starts without such an error. So, if the "smolder" script can find the configs, it seems that "smolderctl" out to be able to find them, too.
RT-Send-CC: swartz [...] pobox.com
Jonathan, Thanks for contributing 'smolderctl'. Perhaps you would be willing to take a look at this bug report that relates to it and add a comment. I also noticed that is virtual no documentation for 'smolderctl'. Some basic documentation would be useful. ( After the 1.51 release, I provided feedback through several other bug reports as well: http://rt.cpan.org/Public/Dist/Display.html? Name=Smolder ) Thanks! Mark
RT-Send-CC: swartz [...] pobox.com
I see the issue now. It's trying to load Server::Control::Simple, but can't find it. This module appears that might be a typo for Server::Control::HTTPServerSimple, another module by Jonathan Swartz, which wasn't listed in the Build.PL for smolder. However, that module itself has a significant chain of dependencies including Moose: http://cpansearch.perl.org/src/JSWARTZ/Server-Control-0.12/Makefile.PL This really seems like overkill for implementing simple functions to stop, start and restart Smolder. I have some interest in providing an alternate, simpler implementation for a ctl script: start - run /bin/smolder stop - send kill -15 to process identified in pid file restart - stop(); start(); Sound reasonable? Mark
Subject: PATCH: alternative smolderctl
RT-Send-CC: swartz [...] pobox.com
Below is a start of alternative, much simpler "smolderctl" It works for me, once I patch in a default value for PidFile into Smolder/Conf.pm. Note that I've left several "XXX" comments for places where it could be improved to be more flexible or better validate input. ### #!/usr/bin/perl use FindBin '$Bin'; # XXX, we need an option to init from another config file. use Smolder::Conf qw(PidFile); use File::Slurp; use Getopt::Long; use warnings; use strict; # You can provide a full path smolder and the args it needs, or default # to running smolder in the same bin directory, with no args. my $smolder_cmd = $Bin.'/smolder'; GetOptions( 'cmd=s' => \$smolder_cmd, ); my $action = $ARGV[0] || die "usage: $0 [start|stop|restart]\n"; # XXX, could be validated further # XXX What doesn't PidFile default to something besides undef? # I recommend adding this to Smolder/Conf.pm: # PidFile => catdir(File::HomeDir->my_data, '.smolder', 'pid'), my $pid_file = Smolder::Conf->get('PidFile'); my $pid = eval { read_file($pid_file ) }; if ($action eq 'start') { # XXX assume it's always OK to pass an extra daemon flag. # XXX Can we be smarter about passing along paths given to "perl - I./" ? # XXX error checking? system("$smolder_cmd --daemon"); } elsif ($action eq 'stop') { kill 15, $pid; } elsif ($action eq 'restart') { kill 15, $pid; system("$smolder_cmd --daemon"); } else { die "action not recognized. Use 'start', 'stop' or 'restart'" }
Subject: Re: [rt.cpan.org #52973] PATCH: alternative smolderctl
Date: Fri, 8 Jan 2010 16:33:34 -0800
To: bug-Smolder [...] rt.cpan.org
From: Jonathan Swartz <swartz [...] pobox.com>
That's fine. People who have already loaded Server::Control can choose to use that instead if they want. :) Jon On Jan 8, 2010, at 3:31 PM, MARKSTOS via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=52973 > > > Below is a start of alternative, much simpler "smolderctl" It works > for > me, once I patch in a default value for PidFile into Smolder/Conf.pm. > > Note that I've left several "XXX" comments for places where it could > be > improved to be more flexible or better validate input. > > ### > > #!/usr/bin/perl > use FindBin '$Bin'; > # XXX, we need an option to init from another config file. > use Smolder::Conf qw(PidFile); > use File::Slurp; > use Getopt::Long; > use warnings; > use strict; > > # You can provide a full path smolder and the args it needs, or > default > # to running smolder in the same bin directory, with no args. > my $smolder_cmd = $Bin.'/smolder'; > GetOptions( 'cmd=s' => \$smolder_cmd, ); > > my $action = $ARGV[0] || die "usage: $0 [start|stop|restart]\n"; > > # XXX, could be validated further > > # XXX What doesn't PidFile default to something besides undef? > # I recommend adding this to Smolder/Conf.pm: > # PidFile => catdir(File::HomeDir->my_data, '.smolder', > 'pid'), > my $pid_file = Smolder::Conf->get('PidFile'); > > my $pid = eval { read_file($pid_file ) }; > > > if ($action eq 'start') { > # XXX assume it's always OK to pass an extra daemon flag. > # XXX Can we be smarter about passing along paths given to "perl - > I./" ? > # XXX error checking? > system("$smolder_cmd --daemon"); > } > elsif ($action eq 'stop') { > kill 15, $pid; > } > elsif ($action eq 'restart') { > kill 15, $pid; > system("$smolder_cmd --daemon"); > } > else { > die "action not recognized. Use 'start', 'stop' or 'restart'" > } >
Subject: integrate smolderctl functionality into bin/smolder?
RT-Send-CC: swartz [...] pobox.com
I've considered this further, and I think the simplest solution is to simply add support for "start/stop/restart" right to bin/smolder OS packagers will make their own "ctl" wrapper scripts anyway that forward the OS conventions. "start" would just map to what "--daemon" does, and "stop" would map to sending a "kill 15" to the pid in the PidFile, like the code above does. "restart" is just stop+start. What do you think Michael? Mark
Subject: Re: [rt.cpan.org #52973] integrate smolderctl functionality into bin/smolder?
Date: Sat, 09 Jan 2010 08:57:49 -0500
To: bug-Smolder [...] rt.cpan.org
From: Michael Peters <mpeters [...] plusthree.com>
On 01/08/2010 10:09 PM, MARKSTOS via RT wrote: Show quoted text
> What do you think Michael?
That's probably ok, but I'm not entirely convinced. I like the separate that just about every other program has from the actual daemon bin and the ctl script. I've gotten in trouble in the past with Smolder for trying to do things differently than people expected because I thought it would make things easier. Maybe the best thing would be to provide a sample ctl script in the documentation (or maybe an examples/ directory) that people (and packagers) could customize. Most people probably won't need a ctl script and I'm not sure we want to install it by default, so maybe having an extra step to set it up would be best anyway. -- Michael Peters Plus Three, LP
I just want to note some other alternatives: - Server::Starter is like Server::Control, but with fewer dependencies, notably "Moose" is not part of the dependency chain. - I have also started a branch to work on making Smolder run on PSGI/Plack. That would allow Smolder to easily run as part of an existing server, including CGI, mod_perl, etc. That branch is here (still an un-tested sketch): http://github.com/markstos/smolder/commit/65ab425bd918c0e43ec14c5d5bab38 650ea23576 I'm also working on improving the PSGI support in CGI::Application and CGI::Application::Dispatch to make such integrations easier and more natural.