This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| use lib 'lib'; | |
| use Test::More; | |
| use Test::Fatal; | |
| { | |
| package R1; | |
| use Role::Tiny; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ perl -E 'package R; use Role::Tiny; sub foo { "R1 foo" }; package R2; use Role::Tiny; sub foo { "R2 foo" }; package X; use Role::Tiny::With; sub new { bless {} }; my $x = X->new; Role::Tiny->apply_roles_to_object($x, "R", "R2"); say $x->foo;' | |
| R2 foo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Sorry, I'm too lazy to file each one of these bugs separately, and I really think you should adopt `Ubic::Daemon` instead. | |
| You should close all filehandles; simple test: `ssh localhost '/etc/init.d/foo start'` will hang otherwise. | |
| `exit 1` if service is already running is not LSB compatible. Also, not supporting force-reload and try-restart. | |
| Not saving pidfile atomically means that your code will break if you recreated the pidfile but failed because of random kill (oom, for example), or after reboot. Simple test: `echo >file.pid` will break your service forever. | |
| If you don't keep any additional guid in your pidfile, this means that at the time you call `/etc/init.d/foo stop`, you can kill the wrong process. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package X; | |
| use Moose; | |
| with 'Yandex::Runnable'; # yeah, I didn't got along well with MooseX::Runnable, don't remember why | |
| sub main { | |
| ... | |
| } | |
| __PACKAGE__->run_script; # magic! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ ./test.t | |
| exception script.pl did not return a true value at ./test.t line 9. | |
| $ perl --version | |
| This is perl, v5.8.8 built for x86_64-linux-gnu-thread-multi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| * * * * * . /Users/mmcleric/etc/bash/local && ubic-watchdog ubic.watchdog >>/dev/null 2>>/dev/null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| use Dancer; | |
| use Ubic; | |
| my @commands = qw( start stop status restart try-restart reload force-reload); | |
| post '/:service/:command' => sub { | |
| my $service = param('service'); | |
| my $command = param('command'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package Wrap; | |
| ... | |
| sub lag { | |
| die unless $self->{wrapped}->DOES('Stream::Role::Lag'); | |
| return $self->{wrapped}->lag; | |
| } | |
| sub DOES { | |
| return $self->{wrapped}->DOES(@_); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package Stream::Out; | |
| # doesn't return anything | |
| sub write_chunk { | |
| } | |
| package Stream::Filter; | |
| # returns rewritten chunk |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package R; | |
| use Moose::Role; | |
| # My::Role::Foo is just a string which affects DOES() behaviour, nothing else | |
| # plan for implementation: | |
| # 1) add MX::Does::Role role to R which wraps DOES with around DOES => sub { ... } | |
| # 2) call $role_metaclass->add_attribute('additional_DOES', ...) | |
| # 3) iterate over role metaclasses in DOES wrapper in MX::Does::Role | |
| use MooseX::DOES qw/ My::Role::Foo My::Role::Bar /; |