Partial database implementation to be able to start with the logic.
All before this commit was boilerplate code...
This commit is contained in:
parent
d8cdb5ac64
commit
8c43403318
@ -7,4 +7,7 @@ WriteMakefile(
|
||||
INST_BIN => './bin',
|
||||
test => { TESTS => 't/*.t' },
|
||||
test => { TESTS => 't/*/*.t' },
|
||||
PREREQ_PM => {
|
||||
'Getopt::Long::Descriptive' => 0,
|
||||
}
|
||||
);
|
||||
|
@ -11,12 +11,31 @@ use IO::Socket::UNIX;
|
||||
use Cualsea::FileSocket;
|
||||
use Cualsea::MessageManager;
|
||||
|
||||
my $command = shift @ARGV or die 'No command passed';
|
||||
my @arguments = @ARGV;
|
||||
|
||||
my $socket = IO::Socket::UNIX->new(
|
||||
Type => SOCK_STREAM(),
|
||||
Peer => $Cualsea::FileSocket::SOCKET_PATH,
|
||||
) or die "Daemon not started";
|
||||
my $message_manager = Cualsea::MessageManager->new(socket => $socket);
|
||||
|
||||
$message_manager->write_message( message => {hola => 'mundo'} );
|
||||
$message_manager->write_message( message => {command => $command, arguments => \@arguments} );
|
||||
|
||||
print Data::Dumper::Dumper $message_manager->read_message;
|
||||
my $message = $message_manager->read_message;
|
||||
|
||||
if ($message->{is_error}) {
|
||||
for ($message->{status}) {
|
||||
if (/^400$/) {
|
||||
say STDERR 'The request was malformed.';
|
||||
exit;
|
||||
}
|
||||
if (/^403$/) {
|
||||
say STDERR 'You are not in the cualsea group.';
|
||||
exit;
|
||||
}
|
||||
say 'Unknown Error';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
print Data::Dumper::Dumper $message;
|
||||
|
@ -7,4 +7,7 @@ WriteMakefile(
|
||||
INST_BIN => './bin',
|
||||
test => { TESTS => 't/*.t' },
|
||||
test => { TESTS => 't/*/*.t' },
|
||||
PREREQ_PM => {
|
||||
'DBD::SQLite' => 0,
|
||||
}
|
||||
);
|
||||
|
@ -9,10 +9,74 @@ use Data::Dumper;
|
||||
use Socket qw/SOL_SOCKET SO_PEERCRED/;
|
||||
|
||||
use Params::ValidationCompiler qw/validation_for/;
|
||||
use Types::Standard qw/Object HashRef/;
|
||||
use Types::Standard qw/Object HashRef Str/;
|
||||
|
||||
use Cualsea::MessageManager;
|
||||
|
||||
my %commands = {
|
||||
add => {
|
||||
params => [
|
||||
'name',
|
||||
'init', # Only sysvinit supported
|
||||
'pidfile',
|
||||
'binpath'
|
||||
],
|
||||
validator => validation_for(
|
||||
params => {
|
||||
name => { type => Str },
|
||||
init => { type => Str },
|
||||
pidfile => { type => Str },
|
||||
binpath => { type => Str },
|
||||
}
|
||||
),
|
||||
},
|
||||
del => {
|
||||
params => [
|
||||
'name'
|
||||
],
|
||||
validator => validation_for(
|
||||
params => {
|
||||
name => { type => Str },
|
||||
}
|
||||
),
|
||||
},
|
||||
report => {
|
||||
params => [],
|
||||
validator => validation_for(
|
||||
params => {},
|
||||
),
|
||||
},
|
||||
start => {
|
||||
params => [
|
||||
'name',
|
||||
],
|
||||
validator => validation_for(
|
||||
params => {
|
||||
name => { type => Str },
|
||||
}
|
||||
),
|
||||
},
|
||||
stop => {
|
||||
params => [
|
||||
'name',
|
||||
],
|
||||
validator => validation_for(
|
||||
params => {
|
||||
name => { type => Str },
|
||||
}
|
||||
),
|
||||
},
|
||||
restart => {
|
||||
params => [
|
||||
'name',
|
||||
],
|
||||
validator => validation_for(
|
||||
params => {
|
||||
name => { type => Str },
|
||||
}
|
||||
),
|
||||
}
|
||||
}
|
||||
sub new {
|
||||
my $class = shift;
|
||||
return bless {}, $class;
|
||||
|
Loading…
Reference in New Issue
Block a user