155 "Will attempt to remove configuration file %s and service directory %s\n",
161 _ (
"Failed to remove configuration file %s\n"),
167 _ (
"Failed to remove servicehome directory %s\n"),
228 return _ (
"Message was sent successfully");
231 return _ (
"We disconnected from ARM before we could send a request");
233 return _ (
"Unknown request status");
249 return _ (
"is stopped");
252 return _ (
"is starting");
255 return _ (
"is stopping");
258 return _ (
"is starting already");
261 return _ (
"is stopping already");
264 return _ (
"is started already");
267 return _ (
"is stopped already");
270 return _ (
"service is not known to ARM");
273 return _ (
"service failed to start");
276 return _ (
"service cannot be manipulated because ARM is shutting down");
278 return _ (
"Unknown result code.");
311 _ (
"Fatal error initializing ARM API.\n"));
340 _ (
"Failed to start the ARM service: %s\n"),
349 _ (
"Failed to start the ARM service: %s\n"),
355 "ARM service [re]start successful\n");
387 "Failed to send a stop request to the ARM service: %s\n")
399 _ (
"Failed to stop the ARM service: %s\n"),
405 "ARM service shutdown successful\n");
412 "Initiating an ARM restart\n");
440 _ (
"Failed to send a request to start the `%s' service: %s\n"),
450 _ (
"Failed to start the `%s' service: %s\n"),
457 "Service %s [re]started successfully\n",
490 "Failed to send a request to kill the `%s' service: %%s\n"),
503 _ (
"Failed to kill the `%s' service: %s\n"),
511 "Service %s stopped successfully\n",
536 unsigned int num_stopped = 0;
537 unsigned int num_started = 0;
538 unsigned int num_stopping = 0;
539 unsigned int num_failed = 0;
540 unsigned int num_finished = 0;
549 _ (
"Failed to request a list of services: %s\n"));
557 if (NULL == service_info)
561 _ (
"Error communicating with ARM. ARM not running?\n"));
566 for (
unsigned int i = 0; i < count; i++)
568 switch (service_info[i].
status)
585 "%s (binary='%s', status=stopping)\n",
586 service_info[i].
name,
587 service_info[i].binary);
592 "%s (binary='%s', status=unknown)\n",
593 service_info[i].
name,
594 service_info[i].binary);
603 _ (
"All services:\n"));
607 _ (
"Services (excluding stopped services):\n"));
608 if (num_stopped || num_failed || num_finished || num_stopping ||
612 fprintf (stdout,
"(");
613 if (0 != num_started)
616 fprintf (stdout,
" / ");
625 fprintf (stdout,
" / ");
631 if (0 != num_stopping)
634 fprintf (stdout,
" / ");
640 if (0 != num_stopped)
643 fprintf (stdout,
" / ");
649 if (0 != num_finished)
652 fprintf (stdout,
" / ");
658 fprintf (stdout,
")\n");
664 _ (
"(No services configured.)\n"));
667 for (
unsigned int i = 0; i < count; i++)
670 switch (service_info[i].
status)
675 "%s (binary='%s', status=stopped)\n",
676 service_info[i].
name,
677 service_info[i].binary);
683 "%s (binary='%s', status=failed, exit_status=%d, restart_delay='%s')\n",
684 service_info[i].
name,
685 service_info[i].binary,
686 service_info[i].last_exit_status,
692 "%s (binary='%s', status=finished)\n",
693 service_info[i].
name,
694 service_info[i].binary);
698 "%s (binary='%s', status=started)\n",
699 service_info[i].
name,
700 service_info[i].binary);
704 "%s (binary='%s', status=stopping)\n",
705 service_info[i].
name,
706 service_info[i].binary);
711 "%s (binary='%s', status=unknown)\n",
712 service_info[i].
name,
713 service_info[i].binary);
734 "Running requested actions\n");
743 "Termination action\n");
760 "GNUnet not running, cannot stop the peer\n");
799 "Initialization action\n");
813 "Going to list all running services controlled by ARM.\n");
826 _ (
"Now only monitoring, press CTRL-C to stop.\n"));
862 msg =
_ (
"Stopped %s.\n");
866 msg =
_ (
"Starting %s...\n");
870 msg =
_ (
"Stopping %s...\n");
885 _ (
"Unknown status %u for service %s.\n"),
890 "Got service %s status %d\n",
970main (
int argc,
char *
const *argv)
990 "also show stopped services (used with -I)"),
995 "start all GNUnet default services"),
1000 "stop and start all GNUnet default services"),
1005 "delete config file and directory on exit"),
1020 "exit with error status if operation does not finish after DELAY"),
1025 "list currently running services"),
1030 gettext_noop (
"don't let gnunet-service-arm inherit standard output"),
1035 gettext_noop (
"don't let gnunet-service-arm inherit standard error"),
1048 "Control services and the Automated Restart Manager (ARM)"),
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_GETOPT_CommandLineOption options[]
struct GNUNET_MessageHeader * msg
#define gettext_noop(String)
static int once
Global to mark if we've run the initialization.
static int no_stdout
Do we want to give our stdout to gnunet-service-arm?
static void timeout_task_cb(void *cls)
Task run on timeout (if -T is given).
static struct GNUNET_ARM_Operation * op
Current operation.
static const char * req_string(enum GNUNET_ARM_RequestStatus rs)
Returns a string interpretation of rs.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
static void term_callback(void *cls, enum GNUNET_ARM_RequestStatus rs, enum GNUNET_ARM_Result result)
We have requested a service to be stopped, this function is called with the result of the operation.
static void delete_files()
Attempts to delete configuration file and GNUNET_HOME on ARM shutdown provided the end and delete opt...
static int start
Set if we are to start default services (including ARM).
static int monitor
Monitor ARM activity.
static int show_all
Set if we should print all services, including stopped ones.
static int list
Set if we should print a list of currently running services.
static int quiet
Set if we should not print status messages.
static void stop_callback(void *cls, enum GNUNET_ARM_RequestStatus rs, enum GNUNET_ARM_Result result)
We have requested ARM to be stopped, this function is called with the result of the operation.
static void shutdown_task(void *cls)
Main continuation-passing-style loop.
static int ret
Final status code.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static char * dir
Set to the directory where runtime files are stored.
static char * term
Set to the name of a service to kill.
static char * init
Set to the name of a service to start.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Main function that will be run by the scheduler.
static void action_loop(void *cls)
Main task that runs our various operations in order.
static int restart
Set if we are to stop/start default services (including ARM).
static const char * ret_string(enum GNUNET_ARM_Result result)
Returns a string interpretation of the result.
static void conn_status(void *cls, int connected)
Function called whenever we connect to or disconnect from ARM.
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
static void list_callback(void *cls, enum GNUNET_ARM_RequestStatus rs, unsigned int count, const struct GNUNET_ARM_ServiceInfo *service_info)
Function called with the list of running services.
static unsigned int phase
Processing stage that we are in.
static struct GNUNET_SCHEDULER_Task * al_task
Handle for the task running the action_loop().
static void srv_status(void *cls, const char *service, enum GNUNET_ARM_ServiceMonitorStatus status)
Function called when a service starts or stops.
static int end
Set if we are to shutdown all services (including ARM).
static char * config_file
Set to the name of the config file used.
static struct GNUNET_SCHEDULER_Task * timeout_task
Task to be run on timeout.
int main(int argc, char *const *argv)
The main function to obtain arm from gnunetd.
static int no_stderr
Do we want to give our stderr to gnunet-service-arm?
static void init_callback(void *cls, enum GNUNET_ARM_RequestStatus rs, enum GNUNET_ARM_Result result)
We have requested a service to be started, this function is called with the result of the operation.
static void start_callback(void *cls, enum GNUNET_ARM_RequestStatus rs, enum GNUNET_ARM_Result result)
We have requested ARM to be started, this function is called with the result of the operation.
static char * name
Name (label) of the records to list.
static int status
The program status; 0 for success.
static int result
Global testing status.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
GNUNET_ARM_ServiceMonitorStatus
Statuses of services.
struct GNUNET_ARM_Handle * GNUNET_ARM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ARM_ConnectionStatusCallback conn_status, void *conn_status_cls)
Set up a context for communicating with ARM, then start connecting to the ARM service using that cont...
struct GNUNET_ARM_Operation * GNUNET_ARM_request_service_start(struct GNUNET_ARM_Handle *h, const char *service_name, enum GNUNET_OS_InheritStdioFlags std_inheritance, GNUNET_ARM_ResultCallback cont, void *cont_cls)
Request for a service to be started.
struct GNUNET_ARM_MonitorHandle * GNUNET_ARM_monitor_start(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ARM_ServiceMonitorCallback cont, void *cont_cls)
Setup a context for monitoring ARM, then start connecting to the ARM service for monitoring using tha...
struct GNUNET_ARM_Operation * GNUNET_ARM_request_service_list(struct GNUNET_ARM_Handle *h, GNUNET_ARM_ServiceListCallback cont, void *cont_cls)
Request a list of running services.
struct GNUNET_ARM_Operation * GNUNET_ARM_request_service_stop(struct GNUNET_ARM_Handle *h, const char *service_name, GNUNET_ARM_ResultCallback cont, void *cont_cls)
Request a service to be stopped.
void GNUNET_ARM_monitor_stop(struct GNUNET_ARM_MonitorHandle *h)
Disconnect from the ARM service and destroy the handle.
void GNUNET_ARM_disconnect(struct GNUNET_ARM_Handle *h)
Disconnect from the ARM service and destroy the handle.
GNUNET_ARM_Result
Replies to ARM requests.
GNUNET_ARM_RequestStatus
Statuses of the requests that client can send to ARM.
void GNUNET_ARM_operation_cancel(struct GNUNET_ARM_Operation *op)
Abort an operation.
@ GNUNET_ARM_SERVICE_STATUS_FINISHED
The service was started, but then exited normally.
@ GNUNET_ARM_SERVICE_STATUS_FAILED
The service has previously failed, and will be restarted.
@ GNUNET_ARM_SERVICE_STATUS_STOPPED
Service is stopped.
@ GNUNET_ARM_SERVICE_STATUS_STOPPING
The service was started, and we're currently waiting for it to be stopped.
@ GNUNET_ARM_SERVICE_STATUS_STARTED
Service has been started and is currently running.
@ GNUNET_ARM_SERVICE_STOPPING
Service stopping was initiated.
@ GNUNET_ARM_SERVICE_STOPPED
Service was stopped.
@ GNUNET_ARM_SERVICE_STARTING
Service starting was initiated.
@ GNUNET_ARM_SERVICE_MONITORING_STARTED
Dummy message.
@ GNUNET_ARM_RESULT_IS_NOT_KNOWN
Asked to start or stop a service, but it's not known.
@ GNUNET_ARM_RESULT_IS_STARTING_ALREADY
Asked to start it, but it's already starting.
@ GNUNET_ARM_RESULT_IS_STOPPED_ALREADY
Asked to stop it, but it's already stopped.
@ GNUNET_ARM_RESULT_STARTING
Service starting was initiated.
@ GNUNET_ARM_RESULT_IS_STARTED_ALREADY
Asked to start it, but it's already started.
@ GNUNET_ARM_RESULT_STOPPING
ARM stopping was initiated (there's no "stopped" for ARM itself).
@ GNUNET_ARM_RESULT_IS_STOPPING_ALREADY
Asked to stop it, but it's already stopping.
@ GNUNET_ARM_RESULT_STOPPED
Service was stopped (never sent for ARM itself).
@ GNUNET_ARM_RESULT_START_FAILED
Tried to start a service, but that failed for some reason.
@ GNUNET_ARM_RESULT_IN_SHUTDOWN
Asked to start something, but ARM is shutting down and can't comply.
@ GNUNET_ARM_REQUEST_DISCONNECTED
We disconnected from ARM, and request was not sent.
@ GNUNET_ARM_REQUEST_SENT_OK
Message was sent successfully.
enum GNUNET_GenericReturnValue GNUNET_CLIENT_test(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name)
Test if the port or UNIXPATH of the given service_name is in use and thus (most likely) the respectiv...
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_remove(const char *filename)
Remove all files in a directory (rm -rf).
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_relative_time(char shortName, const char *name, const char *argumentHelp, const char *description, struct GNUNET_TIME_Relative *val)
Allow user to specify a struct GNUNET_TIME_Relative (using human-readable "fancy" time).
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
#define GNUNET_log(kind,...)
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_free(ptr)
Wrapper around free.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
@ GNUNET_OS_INHERIT_STD_OUT
When this flag is set, the child process will inherit stdout of the parent.
@ GNUNET_OS_INHERIT_STD_ERR
When this flag is set, the child process will inherit stderr of the parent.
@ GNUNET_OS_INHERIT_STD_NONE
No standard streams should be inherited.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(const struct GNUNET_OS_ProjectData *pd, int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Handle for interacting with ARM.
Handle for interacting with ARM.
Entry in a doubly-linked list of operations awaiting for replies (in-order) from the ARM service.
Information about a service managed by ARM.
Definition of a command line option.
Entry in list of pending tasks.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.