+ Put ipc in directory

This commit is contained in:
Quentin Garnier 2014-10-29 11:50:35 +01:00
parent 8c2ed7124f
commit e88ce52fc2
2 changed files with 25 additions and 8 deletions

View File

@ -164,7 +164,7 @@ sub reqclient {
$self->{modules_registry}->{$result->{command}}->initArgs(arguments => $result);
$self->{modules_registry}->{$result->{command}}->run();
centreon::esxd::common::response(token => 'RESPSERVER2', endpoint => $backend, reinit => 'ipc://routing.ipc');
centreon::esxd::common::response(token => 'RESPSERVER2', endpoint => $backend, reinit => 'ipc:///tmp/centreonesxd/routing.ipc');
zmq_close($backend);
exit(0);
}
@ -198,7 +198,7 @@ sub run {
$backend = zmq_socket($context, ZMQ_DEALER);
zmq_setsockopt($backend, ZMQ_IDENTITY, "server-" . $connector->{whoaim});
zmq_setsockopt($backend, ZMQ_LINGER, 0); # we discard
zmq_connect($backend, 'ipc://routing.ipc');
zmq_connect($backend, 'ipc:///tmp/centreonesxd/routing.ipc');
centreon::esxd::common::response(token => 'READY', endpoint => $backend, stdout => '');
# Initialize poll set

View File

@ -451,6 +451,24 @@ sub create_vsphere_child {
$self->{centreonesxd_config}->{vsphere_server}->{$self->{whoaim}}->{pid} = $child_vpshere_pid;
}
sub bind_ipc {
my ($self, %options) = @_;
if (zmq_bind($options{socket}, 'ipc://' . $options{ipc_file}) == -1) {
$self->{logger}->writeLogError("Cannot bind ipc '$options{ipc_file}': $!");
# try create dir
$self->{logger}->writeLogError("Maybe dirctory not exist. We try to create it!!!");
if (!mkdir(dirname($options{ipc_file}))) {
zmq_close($options{socket});
exit(1);
}
if (zmq_bind($options{socket}, 'ipc://' . $options{ipc_file}) == -1) {
zmq_close($options{socket});
exit(1);
}
}
}
sub run {
$centreonesxd = shift;
@ -462,16 +480,15 @@ sub run {
my $context = zmq_init();
$frontend = zmq_socket($context, ZMQ_ROUTER);
zmq_setsockopt($frontend, ZMQ_LINGER, 0); # we discard
zmq_bind($frontend, 'tcp://*:5700');
zmq_bind($frontend, 'ipc://routing.ipc');
if (!defined($frontend)) {
$centreonesxd->{logger}->writeLogError("Can't setup server: $!");
exit(1);
}
zmq_setsockopt($frontend, ZMQ_LINGER, 0); # we discard
zmq_bind($frontend, 'tcp://*:5700');
$centreonesxd->bind_ipc(socket => $frontend, ipc_file => '/tmp/centreonesxd/routing.ipc');
foreach (keys %{$centreonesxd->{centreonesxd_config}->{vsphere_server}}) {
$centreonesxd->{counter_stats}->{$_} = 0;
$centreonesxd->create_vsphere_child(vsphere_name => $_, dynamic => 0);