Skip to content

Commit 002adc7

Browse files
kcudniklguohan
authored andcommitted
Add support for sairedis logrotate (sonic-net#242)
1 parent bc755b8 commit 002adc7

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

orchagent/main.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ extern "C" {
1717

1818
#include "orchdaemon.h"
1919
#include "saihelper.h"
20+
#include <signal.h>
2021

2122
using namespace std;
2223
using namespace swss;
@@ -70,12 +71,35 @@ void usage()
7071
cout << " -m MAC: set switch MAC address" << endl;
7172
}
7273

74+
void sighup_handler(int signo)
75+
{
76+
/*
77+
* Don't do any logging since they are using mutexes.
78+
*/
79+
80+
sai_attribute_t attr;
81+
82+
attr.id = SAI_REDIS_SWITCH_ATTR_PERFORM_LOG_ROTATE;
83+
attr.value.booldata = true;
84+
85+
if (sai_switch_api != NULL)
86+
{
87+
sai_switch_api->set_switch_attribute(&attr);
88+
}
89+
}
90+
7391
int main(int argc, char **argv)
7492
{
7593
swss::Logger::linkToDbNative("orchagent");
7694

7795
SWSS_LOG_ENTER();
7896

97+
if (signal(SIGHUP, sighup_handler) == SIG_ERR)
98+
{
99+
SWSS_LOG_ERROR("failed to setup SIGHUP action");
100+
exit(1);
101+
}
102+
79103
int opt;
80104
sai_status_t status;
81105

0 commit comments

Comments
 (0)