Skip to content
Snippets Groups Projects
Commit 85c1e1d0 authored by Eric Vidal's avatar Eric Vidal :speech_balloon:
Browse files

Merge branch 'async' into dev

parents b553427a 78da40a8
Branches
Tags
No related merge requests found
......@@ -31,6 +31,8 @@
#define SS_TREE_LEN (sizeof SS_TREE - 1)
#define SS_NOTIFICATION "notification-fd"
#define SS_NOTIFICATION_LEN (sizeof SS_NOTIFICATION - 1)
#define SS_MAXDEATHTALLY "max-death-tally"
#define SS_MAXDEATHTALLY_LEN (sizeof SS_MAXDEATHTALLY - 1)
/**tree dir*/
#define SS_RULES "/rules"
#define SS_RULES_LEN (sizeof SS_RULES - 1)
......
......@@ -23,7 +23,7 @@
#include <66/resolve.h>
#include <66/ssexec.h>
typedef struct ss_resolve_sig_s ss_resolve_sig_t, *ss_resovle_sig_t_ref ;
typedef struct ss_resolve_sig_s ss_resolve_sig_t, *ss_resolve_sig_t_ref ;
struct ss_resolve_sig_s
{
ss_resolve_t res ;
......@@ -77,7 +77,7 @@ enum sigactions_e
extern int svc_switch_to(ssexec_t *info,unsigned int where) ;
extern int svc_init(ssexec_t *info,char const *src, genalloc *ga) ;
extern int svc_init_pipe(ftrigr_t *fifo,genalloc *gasv) ;
extern int svc_init_pipe(ftrigr_t *fifo,genalloc *gasv,tain_t *deadline) ;
extern int svc_send(ssexec_t *info,genalloc *ga,char const *sig,char const *const *envp) ;
extern int svc_unsupervise(ssexec_t *info,genalloc *ga,char const *sig,char const *const *envp) ;
......
......@@ -100,7 +100,7 @@ char const *help_stop =
" -K: kill the service(s) and keep it down\n"
;
char const *usage_svctl = "66-svctl [ -h ] [ -v verbosity ] [ -l live ] [ -t tree ] [ -T timeout ] [ -n death ] [ -u | U | d | D | r | R | K | X ] service(s)" ;
char const *usage_svctl = "66-svctl [ -h ] [ -v verbosity ] [ -l live ] [ -t tree ] [ -T timeout ] [ -n death ] [ -u | d | r | K | X ] service(s)" ;
char const *help_svctl =
"66-svctl <options> tree\n"
......@@ -113,11 +113,8 @@ char const *help_svctl =
" -T: service timeout\n"
" -n: number of death\n"
" -u: bring up the service(s)\n"
" -U: really up\n"
" -d: bring down the service(s)\n"
" -D: really down\n"
" -r: reload\n"
" -R: reload and really up\n"
" -X: bring down the service(s) and the kill his supervisor\n"
" -K: kill the service(s) and keep it down\n"
;
......
......@@ -13,7 +13,7 @@
*/
#include <string.h>
//#include <stdio.h>
#include <stdio.h>
#include <oblibs/obgetopt.h>
#include <oblibs/error2.h>
......@@ -35,7 +35,7 @@
static int empty = 0 ;
static unsigned int RELOAD = 0 ;
static unsigned int DEADLINE = 0 ;
static char *SIG = "-U" ;
static char *SIG = "-u" ;
static genalloc nclassic = GENALLOC_ZERO ; //resolve_t type
static genalloc nrc = GENALLOC_ZERO ; //resolve_t type
......@@ -63,7 +63,7 @@ int svc_sanitize(ssexec_t *info, char const *const *envp)
VERBO1 strerr_warnwu1sys("publish service graph") ;
goto err ;
}
if (!svc_unsupervise(info,&graph_reload_cl.sorted,"-D",envp)) goto err ;
if (!svc_unsupervise(info,&graph_reload_cl.sorted,"-d",envp)) goto err ;
genalloc_reverse(ss_resolve_t,&graph_reload_cl.sorted) ;
if (!svc_init(info,sares.s,&graph_reload_cl.sorted))
{
......@@ -202,7 +202,7 @@ int ssexec_start(int argc, char const *const *argv,char const *const *envp,ssexe
// be sure that the global var are set correctly
RELOAD = 0 ;
DEADLINE = 0 ;
SIG = "-U" ;
SIG = "-u" ;
if (info->timeout) DEADLINE = info->timeout ;
......@@ -228,7 +228,7 @@ int ssexec_start(int argc, char const *const *argv,char const *const *envp,ssexe
switch (opt)
{
case 'r' : if (RELOAD) exitusage(usage_start) ; RELOAD = 1 ; SIG = "-r" ; break ;
case 'R' : if (RELOAD) exitusage(usage_start) ; RELOAD = 2 ; SIG = "-U" ; break ;
case 'R' : if (RELOAD) exitusage(usage_start) ; RELOAD = 2 ; SIG = "-u" ; break ;
default : exitusage(usage_start) ;
}
}
......
......@@ -32,7 +32,7 @@
static unsigned int DEADLINE = 0 ;
static unsigned int UNSUP = 0 ;
static char *SIG = "-D" ;
static char *SIG = "-d" ;
static ss_resolve_graph_t graph_unsup_cl = RESOLVE_GRAPH_ZERO ;
static ss_resolve_graph_t graph_cl = RESOLVE_GRAPH_ZERO ;
......@@ -115,7 +115,7 @@ int ssexec_stop(int argc, char const *const *argv,char const *const *envp,ssexec
// be sure that the global var are set correctly
DEADLINE = 0 ;
UNSUP = 0 ;
SIG = "-D" ;
SIG = "-d" ;
if (info->timeout) DEADLINE = info->timeout ;
......
This diff is collapsed.
......@@ -31,27 +31,18 @@
#include <66/resolve.h>
int svc_init_pipe(ftrigr_t *fifo,genalloc *gasv)
int svc_init_pipe(ftrigr_t *fifo,genalloc *gasv,tain_t *deadline)
{
tain_t ttmain ;
tain_now_g() ;
tain_addsec(&ttmain,&STAMP,2) ;
ss_resolve_sig_t *svc ;
//VERBO2 strerr_warni1x("initiate fifo: fifo") ;
if (!ftrigr_startf(fifo, &ttmain, &STAMP))
if (!ftrigr_startf_g(fifo, deadline))
VERBO3 { strerr_warnwu1sys("initiate fifo") ; return 0 ; }
for (unsigned int i = 0 ; i < genalloc_len(ss_resolve_sig_t,gasv) ; i++)
{
svc = &genalloc_s(ss_resolve_sig_t,gasv)[i] ;
int r ;
size_t siglen = strlen(svc->sigtosend) ;
char *svok = svc->res.sa.s + svc->res.runat ;
size_t scanlen = strlen(svok) ;
char svfifo[scanlen + 6 + 1] ;
memcpy(svfifo, svok,scanlen) ;
memcpy(svfifo + scanlen, "/event",6) ;
......@@ -65,31 +56,14 @@ int svc_init_pipe(ftrigr_t *fifo,genalloc *gasv)
}
VERBO3 strerr_warnt2x("subcribe to fifo: ",svfifo) ;
svc->ids = ftrigr_subscribe_g(fifo, svfifo, "[DuUdOxs]", FTRIGR_REPEAT, &ttmain) ;
svc->ids = ftrigr_subscribe_g(fifo, svfifo, "[DuUdOxs]", FTRIGR_REPEAT, deadline) ;
if (!svc->ids)
{
VERBO3 strerr_warnwu2sys("subcribe to fifo: ",svfifo) ;
goto end ;
}
VERBO3 strerr_warnt6x("send signal: ",svc->sigtosend," to: ", svok,"/",S6_SUPERVISE_CTLDIR) ;
r = s6_svc_writectl(svok, S6_SUPERVISE_CTLDIR, svc->sigtosend, siglen) ;
if (r < 0)
{
VERBO3 strerr_warnwu3sys("something is wrong with the ",svok, "/" S6_SUPERVISE_CTLDIR " directory. errno reported") ;
goto end ;
}
if (!r)
{
VERBO3 strerr_warnw3x("sv: ",svok, " is not supervised") ;
goto end ;
}
}
return 1 ;
end:
return 0 ;
}
......@@ -22,15 +22,13 @@
#include <66/resolve.h>
#include <66/ssexec.h>
int svc_send(ssexec_t *info,genalloc *ga,char const *sig,char const *const *envp)
{
unsigned int i = 0 ;
int nargc = 3 + genalloc_len(ss_resolve_t,ga) ;
char const *newargv[nargc] ;
unsigned int m = 0 ;
newargv[m++] = "fake_name" ;
newargv[m++] = sig ;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment