|
|
|
@ -123,6 +123,7 @@ void read_arguments( s_manager *smanager){
|
|
|
|
|
char *str_database_username = "database_username=\""; |
|
|
|
|
char *str_database_password = "database_password=\""; |
|
|
|
|
|
|
|
|
|
sd_notifyf( 0, "STATUS=Read arguments" ); |
|
|
|
|
|
|
|
|
|
file = open( CLIENT_MANAGER_CONF, O_RDONLY ); |
|
|
|
|
if( file == -1 ){ |
|
|
|
@ -311,11 +312,23 @@ int init_daemon(int flags){
|
|
|
|
|
|
|
|
|
|
int maxfd, fd; |
|
|
|
|
|
|
|
|
|
switch (fork()) { |
|
|
|
|
case -1:
|
|
|
|
|
/* Comunicar com systemd
|
|
|
|
|
* https://manpages.org/sd_notify/3
|
|
|
|
|
*/ |
|
|
|
|
sd_notifyf( 0, "MAINPID=%d", getpid() ); |
|
|
|
|
|
|
|
|
|
pid_t pid_child = fork(); |
|
|
|
|
switch (pid_child) { |
|
|
|
|
case -1: |
|
|
|
|
return -1; |
|
|
|
|
case 0: break; |
|
|
|
|
default: _exit(EXIT_SUCCESS); |
|
|
|
|
default: |
|
|
|
|
/* https://manpages.org/sd_notify/3
|
|
|
|
|
* Biblioteca libsystemd-dev |
|
|
|
|
* comunicação com o systemd que o pid principal mudou |
|
|
|
|
*/ |
|
|
|
|
sd_notifyf( 0, "MAINPID=%d", pid_child ); |
|
|
|
|
_exit(EXIT_SUCCESS); |
|
|
|
|
}/* processo roda em background */ |
|
|
|
|
|
|
|
|
|
if (setsid() == -1) |
|
|
|
@ -353,18 +366,6 @@ int init_daemon(int flags){
|
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* https://manpages.org/sd_notify/3
|
|
|
|
|
* Biblioteca libsystemd-dev |
|
|
|
|
* comunicação com o systemd |
|
|
|
|
*/ |
|
|
|
|
#ifdef SYSTEMD |
|
|
|
|
int re_systemd = sd_notify( 0, "READY=1" ); |
|
|
|
|
_LOG("SYSTEMD READY=1: %d", re_systemd); |
|
|
|
|
pid_t pid= getpid(); |
|
|
|
|
re_systemd = sd_notifyf( 0, "MAINPID=%d", pid ); |
|
|
|
|
_LOG("SYSTEMD MAINPID%d= %d", pid, re_systemd); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -417,8 +418,10 @@ int main (int argc, char **argv){
|
|
|
|
|
} |
|
|
|
|
attempt++; |
|
|
|
|
} |
|
|
|
|
sd_notifyf( 0, "STATUS=Asterisk conectado" ); |
|
|
|
|
_NOTICE("conectado com asterisk"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Essa thread é do banco de dados */ |
|
|
|
|
pthread_create(&thread, NULL, init_thread, (void *)smanager); |
|
|
|
|
|
|
|
|
|