156 "Will attempt to remove configuration file %s and service directory %s\n",
162 _ (
"Failed to remove configuration file %s\n"),
168 _ (
"Failed to remove servicehome directory %s\n"),
204 if (NULL != timeout_task)
229 return _ (
"Message was sent successfully");
232 return _ (
"We disconnected from ARM before we could send a request");
234 return _ (
"Unknown request status");
250 return _ (
"is stopped");
253 return _ (
"is starting");
256 return _ (
"is stopping");
259 return _ (
"is starting already");
262 return _ (
"is stopping already");
265 return _ (
"is started already");
268 return _ (
"is stopped already");
271 return _ (
"service is not known to ARM");
274 return _ (
"service failed to start");
277 return _ (
"service cannot be manipulated because ARM is shutting down");
279 return _ (
"Unknown result code.");
312 _ (
"Fatal error initializing ARM API.\n"));
341 _ (
"Failed to start the ARM service: %s\n"),
350 _ (
"Failed to start the ARM service: %s\n"),
356 "ARM service [re]start successful\n");
388 "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"));
561 _ (
"Error communicating with ARM. ARM not running?\n"));
566 for (
unsigned int i = 0; i < count; i++)
585 "%s (binary='%s', status=stopping)\n",
592 "%s (binary='%s', status=unknown)\n",
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++)
675 "%s (binary='%s', status=stopped)\n",
682 "%s (binary='%s', status=failed, exit_status=%d, restart_delay='%s')\n",
685 list[i].last_exit_status,
691 "%s (binary='%s', status=finished)\n",
697 "%s (binary='%s', status=started)\n",
703 "%s (binary='%s', status=stopping)\n",
710 "%s (binary='%s', status=unknown)\n",
733 "Running requested actions\n");
742 "Termination action\n");
759 "GNUnet not running, cannot stop the peer\n");
798 "Initialization action\n");
812 "Going to list all running services controlled by ARM.\n");
825 _ (
"Now only monitoring, press CTRL-C to stop.\n"));
861 msg =
_ (
"Stopped %s.\n");
865 msg =
_ (
"Starting %s...\n");
869 msg =
_ (
"Stopping %s...\n");
884 _ (
"Unknown status %u for service %s.\n"),
889 "Got service %s status %d\n",
969 main (
int argc,
char *
const *argv)
989 "also show stopped services (used with -I)"),
994 "start all GNUnet default services"),
999 "stop and start all GNUnet default services"),
1004 "delete config file and directory on exit"),
1019 "exit with error status if operation does not finish after DELAY"),
1024 "list currently running services"),
1029 gettext_noop (
"don't let gnunet-service-arm inherit standard output"),
1034 gettext_noop (
"don't let gnunet-service-arm inherit standard error"),
1052 "Control services and the Automated Restart Manager (ARM)"),
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)...
The service has previously failed, and will be restarted.
static struct GNUNET_SCHEDULER_Task * al_task
Handle for the task running the action_loop().
static char * dir
Set to the directory where runtime files are stored.
ARM stopping was initiated (there's no "stopped" for ARM itself).
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.
Service stopping was initiated.
When this flag is set, the child process will inherit stderr of the parent.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
struct GNUNET_MessageHeader * msg
static unsigned int phase
Processing stage that we are in.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(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, parse options).
static void timeout_task_cb(void *cls)
Task run on timeout (if -T is given).
static void list_callback(void *cls, enum GNUNET_ARM_RequestStatus rs, unsigned int count, const struct GNUNET_ARM_ServiceInfo *list)
Function called with the list of running services.
uint64_t rel_value_us
The actual value.
The service was started, but then exited normally.
static int end
Set if we are to shutdown all services (including ARM).
Asked to stop it, but it's already stopping.
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 int restart
Set if we are to stop/start default services (including ARM).
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, or when GNUNET_SCHEDULER_shutdown() is being invoked.
static int start
Set if we are to start default services (including ARM).
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Entry in a doubly-linked list of operations awaiting for replies (in-order) from the ARM service...
static char * config_file
Set to the name of the config file used.
We disconnected from ARM, and request was not sent.
Handle for interacting with ARM.
void GNUNET_ARM_operation_cancel(struct GNUNET_ARM_Operation *op)
Abort an operation.
GNUNET_ARM_Result
Replies to ARM requests.
Definition of a command line option.
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.
Handle for interacting with ARM.
Asked to start it, but it's already started.
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 int quiet
Set if we should not print status messages.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
static int ret
Final status code.
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.
void GNUNET_ARM_disconnect(struct GNUNET_ARM_Handle *h)
Disconnect from the ARM service (if connected) and destroy the context.
static char * term
Set to the name of a service to kill.
static int show_all
Set if we should print all services, including stopped ones.
The service was started, and we're currently waiting for it to be stopped.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
static struct GNUNET_ARM_Handle * h
Connection with ARM.
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.
int main(int argc, char *const *argv)
The main function to obtain arm from gnunetd.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
static void shutdown_task(void *cls)
Main continuation-passing-style loop.
static void srv_status(void *cls, const char *service, enum GNUNET_ARM_ServiceMonitorStatus status)
Function called when a service starts or stops.
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.
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
Tried to start a service, but that failed for some reason.
static void delete_files()
Attempts to delete configuration file and GNUNET_HOME on ARM shutdown provided the end and delete opt...
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_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
Service starting was initiated.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
No standard streams should be inherited.
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.
When this flag is set, the child process will inherit stdout of the parent.
static void conn_status(void *cls, int connected)
Function called whenever we connect to or disconnect from ARM.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
static int once
Global to mark if we've run the initialization.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
uint16_t status
See PRISM_STATUS_*-constants.
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.
Asked to start it, but it's already starting.
static int result
Global testing status.
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_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...
int 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...
Asked to start something, but ARM is shutting down and can't comply.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static const char * ret_string(enum GNUNET_ARM_Result result)
Returns a string interpretation of the result.
#define GNUNET_free_nz(ptr)
Wrapper around free.
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.
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...
Service has been started and is currently running.
Service starting was initiated.
static struct GNUNET_SCHEDULER_Task * timeout_task
Task to be run on timeout.
static char * init
Set to the name of a service to start.
Asked to stop it, but it's already stopped.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
void GNUNET_ARM_monitor_stop(struct GNUNET_ARM_MonitorHandle *h)
Disconnect from the ARM service (if connected) and destroy the context.
Message was sent successfully.
static const char * req_string(enum GNUNET_ARM_RequestStatus rs)
Returns a string interpretation of rs.
GNUNET_ARM_RequestStatus
Statuses of the requests that client can send to 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 int monitor
Monitor ARM activity.
static int no_stderr
Do we want to give our stderr to gnunet-service-arm?
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.
static void action_loop(void *cls)
Main task that runs our various operations in order.
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Information about a service managed by ARM.
Asked to start or stop a service, but it's not known.
GNUNET_ARM_ServiceMonitorStatus
Statuses of services.
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?
static int no_stdout
Do we want to give our stdout to gnunet-service-arm?
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_remove(const char *filename)
Remove all files in a directory (rm -rf).
static struct GNUNET_ARM_Operation * op
Current operation.
Service was stopped (never sent for ARM itself).
static int list
Set if we should print a list of currently running services.
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
#define gettext_noop(String)
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.