2014-05-29 07:11:27 +00:00
|
|
|
/*
|
2016-10-12 06:38:26 +00:00
|
|
|
Serval DNA server main loop
|
|
|
|
Copyright (C) 2012-2015 Serval Project Inc.
|
|
|
|
Copyright (C) 2016 Flinders University
|
2014-05-29 07:11:27 +00:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __SERVAL_DNA__SERVER_H
|
|
|
|
#define __SERVAL_DNA__SERVER_H
|
|
|
|
|
2016-10-12 06:38:26 +00:00
|
|
|
#include "fdqueue.h"
|
|
|
|
#include "os.h" // for time_ms_t
|
2017-09-12 05:54:10 +00:00
|
|
|
#include "trigger.h"
|
2016-10-12 06:38:26 +00:00
|
|
|
|
|
|
|
enum server_mode {
|
|
|
|
SERVER_NOT_RUNNING = 0,
|
|
|
|
SERVER_RUNNING = 1,
|
|
|
|
SERVER_CLOSING = 2
|
|
|
|
};
|
2014-06-11 04:13:56 +00:00
|
|
|
|
2014-05-29 07:11:27 +00:00
|
|
|
DECLARE_ALARM(server_shutdown_check);
|
|
|
|
DECLARE_ALARM(server_watchdog);
|
|
|
|
DECLARE_ALARM(server_config_reload);
|
|
|
|
DECLARE_ALARM(rhizome_sync_announce);
|
|
|
|
DECLARE_ALARM(fd_periodicstats);
|
|
|
|
|
2016-10-12 06:38:26 +00:00
|
|
|
extern __thread enum server_mode serverMode;
|
2014-08-25 04:54:00 +00:00
|
|
|
|
2016-10-12 06:38:26 +00:00
|
|
|
/** Return the PID of the currently running server process, return 0 if there is none.
|
|
|
|
*/
|
2014-08-25 04:54:00 +00:00
|
|
|
int server_pid();
|
2016-10-12 06:38:26 +00:00
|
|
|
|
|
|
|
int server_bind();
|
|
|
|
|
2017-09-12 05:54:10 +00:00
|
|
|
void server_close();
|
|
|
|
|
2016-10-12 06:38:26 +00:00
|
|
|
void server_loop(time_ms_t (*waiting)(time_ms_t, time_ms_t, time_ms_t), void (*wokeup)());
|
2014-08-25 04:54:00 +00:00
|
|
|
|
2018-03-26 12:05:34 +00:00
|
|
|
int server_write_proc_state(const char *path, const char *fmt, ...);
|
|
|
|
int server_unlink_proc_state(const char *path);
|
|
|
|
|
2017-03-06 03:31:14 +00:00
|
|
|
void server_rhizome_add_bundle(uint64_t rowid);
|
|
|
|
|
2018-04-03 05:02:06 +00:00
|
|
|
DECLARE_TRIGGER(startup);
|
2017-09-12 05:54:10 +00:00
|
|
|
DECLARE_TRIGGER(shutdown);
|
|
|
|
|
2014-05-29 07:11:27 +00:00
|
|
|
#endif // __SERVAL_DNA__SERVER_H
|