mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 01:58:20 +00:00
Implement minimal supervised cluster configuration
More aspects of the cluster configuration to get fleshed out later, but a basic cluster like one would use for a live deployment can now be instantiated and run under supervision. The new clusterized-pcap-processing supervisor mode is also not done yet.
This commit is contained in:
parent
25a8ba99fa
commit
29f386e388
12 changed files with 390 additions and 91 deletions
36
src/util.cc
36
src/util.cc
|
@ -1165,17 +1165,22 @@ string flatten_script_name(const string& name, const string& prefix)
|
|||
}
|
||||
|
||||
vector<string>* tokenize_string(string input, const string& delim,
|
||||
vector<string>* rval)
|
||||
vector<string>* rval, int limit)
|
||||
{
|
||||
if ( ! rval )
|
||||
rval = new vector<string>();
|
||||
|
||||
size_t n;
|
||||
auto found = 0;
|
||||
|
||||
while ( (n = input.find(delim)) != string::npos )
|
||||
{
|
||||
++found;
|
||||
rval->push_back(input.substr(0, n));
|
||||
input.erase(0, n + 1);
|
||||
|
||||
if ( limit && found == limit )
|
||||
break;
|
||||
}
|
||||
|
||||
rval->push_back(input);
|
||||
|
@ -1456,7 +1461,7 @@ void terminate_processing()
|
|||
}
|
||||
|
||||
extern const char* proc_status_file;
|
||||
void _set_processing_status(const char* status)
|
||||
void set_processing_status(const char* status, const char* reason)
|
||||
{
|
||||
if ( ! proc_status_file )
|
||||
return;
|
||||
|
@ -1483,20 +1488,27 @@ void _set_processing_status(const char* status)
|
|||
return;
|
||||
}
|
||||
|
||||
int len = strlen(status);
|
||||
while ( len )
|
||||
auto write_str = [](int fd, const char* s)
|
||||
{
|
||||
int n = write(fd, status, len);
|
||||
int len = strlen(s);
|
||||
while ( len )
|
||||
{
|
||||
int n = write(fd, s, len);
|
||||
|
||||
if ( n < 0 && errno != EINTR && errno != EAGAIN )
|
||||
// Ignore errors, as they're too difficult to
|
||||
// safely report here.
|
||||
break;
|
||||
if ( n < 0 && errno != EINTR && errno != EAGAIN )
|
||||
// Ignore errors, as they're too difficult to
|
||||
// safely report here.
|
||||
break;
|
||||
|
||||
status += n;
|
||||
len -= n;
|
||||
}
|
||||
s += n;
|
||||
len -= n;
|
||||
}
|
||||
};
|
||||
|
||||
write_str(fd, status);
|
||||
write_str(fd, " [");
|
||||
write_str(fd, reason);
|
||||
write_str(fd, "]\n");
|
||||
safe_close(fd);
|
||||
|
||||
errno = old_errno;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue