Subversion Repositories Mokou

Rev

Rev 8 | Rev 12 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8 Rev 10
Line 1... Line 1...
1
/* $Id: service.c 8 2024-09-07 09:22:48Z nishi $ */
1
/* $Id: service.c 10 2024-09-07 09:55:12Z nishi $ */
2
 
2
 
3
#include "mk_service.h"
3
#include "mk_service.h"
4
 
4
 
5
#include <fcntl.h>
5
#include <fcntl.h>
6
#include <stdio.h>
6
#include <stdio.h>
Line 394... Line 394...
394
	int i;
394
	int i;
395
	for(i = 0; services[i] != NULL; i++){
395
	for(i = 0; services[i] != NULL; i++){
396
		mk_start_service(services[i]->name);
396
		mk_start_service(services[i]->name);
397
	}
397
	}
398
}
398
}
-
 
399
 
-
 
400
void mk_resurrect_services(void){
-
 
401
	int i;
-
 
402
	bool re = false;
-
 
403
	for(i = 0; services[i] != NULL; i++){
-
 
404
		if(!services[i]->stopped){
-
 
405
			bool alive = false;
-
 
406
 
-
 
407
			FILE* f = fopen(services[i]->pidfile, "r");
-
 
408
			if(f != NULL){
-
 
409
				unsigned long long pid;
-
 
410
				fscanf(f, "%llu", &pid);
-
 
411
				fclose(f);
-
 
412
				alive = kill(pid, 0) == 0;
-
 
413
			}
-
 
414
			if(!alive){
-
 
415
				if(!re){
-
 
416
					mk_log("Resurrection");
-
 
417
					re = true;
-
 
418
				}
-
 
419
				mk_start_service(services[i]->name);
-
 
420
			}
-
 
421
		}
-
 
422
	}
-
 
423
}