diff options
author | Nathan S. Evans <evans@in.tum.de> | 2011-07-26 18:22:54 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2011-07-26 18:22:54 +0000 |
commit | 81eae49a1b5dfeadb9aac5974ec87cd01aed9ffd (patch) | |
tree | 35b65462b9209af4bd610552bb485ad22487400e /src/testing/testing.c | |
parent | bf4a9d8364675b34ac18d505e508006e2b773670 (diff) | |
download | gnunet-81eae49a1b5dfeadb9aac5974ec87cd01aed9ffd.tar.gz gnunet-81eae49a1b5dfeadb9aac5974ec87cd01aed9ffd.zip |
start service
Diffstat (limited to 'src/testing/testing.c')
-rw-r--r-- | src/testing/testing.c | 89 |
1 files changed, 82 insertions, 7 deletions
diff --git a/src/testing/testing.c b/src/testing/testing.c index 79c67e89c..a079390ad 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -1043,12 +1043,12 @@ GNUNET_TESTING_daemon_running (struct GNUNET_TESTING_Daemon *daemon) | |||
1043 | 1043 | ||
1044 | 1044 | ||
1045 | /** | 1045 | /** |
1046 | * Stops a GNUnet daemon. | 1046 | * Starts a GNUnet daemon service which has been previously stopped. |
1047 | * | 1047 | * |
1048 | * @param d the daemon for which the service should be started | 1048 | * @param d the daemon for which the service should be started |
1049 | * @param service the name of the service to start | 1049 | * @param service the name of the service to start |
1050 | * @param timeout how long to wait for process for shutdown to complete | 1050 | * @param timeout how long to wait for process for shutdown to complete |
1051 | * @param cb function called once the daemon was stopped | 1051 | * @param cb function called once the service starts |
1052 | * @param cb_cls closure for cb | 1052 | * @param cb_cls closure for cb |
1053 | */ | 1053 | */ |
1054 | void | 1054 | void |
@@ -1069,13 +1069,9 @@ GNUNET_TESTING_daemon_start_stopped_service (struct GNUNET_TESTING_Daemon *d, | |||
1069 | d->phase = SP_START_DONE; | 1069 | d->phase = SP_START_DONE; |
1070 | } | 1070 | } |
1071 | 1071 | ||
1072 | #if DEBUG_TESTING | ||
1073 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1074 | _("Terminating peer `%4s'\n"), GNUNET_i2s (&d->id)); | ||
1075 | #endif | ||
1076 | if (d->churned_services == NULL) | 1072 | if (d->churned_services == NULL) |
1077 | { | 1073 | { |
1078 | d->dead_cb(d->dead_cb_cls, "No service has been churned off yet!!"); | 1074 | d->cb(d->cb_cls, &d->id, d->cfg, d, "No service has been churned off yet!!"); |
1079 | return; | 1075 | return; |
1080 | } | 1076 | } |
1081 | d->phase = SP_SERVICE_START; | 1077 | d->phase = SP_SERVICE_START; |
@@ -1132,6 +1128,85 @@ GNUNET_TESTING_daemon_start_stopped_service (struct GNUNET_TESTING_Daemon *d, | |||
1132 | } | 1128 | } |
1133 | 1129 | ||
1134 | /** | 1130 | /** |
1131 | * Starts a GNUnet daemon's service. | ||
1132 | * | ||
1133 | * @param d the daemon for which the service should be started | ||
1134 | * @param service the name of the service to start | ||
1135 | * @param timeout how long to wait for process for startup | ||
1136 | * @param cb function called once gnunet-arm returns | ||
1137 | * @param cb_cls closure for cb | ||
1138 | */ | ||
1139 | void | ||
1140 | GNUNET_TESTING_daemon_start_service (struct GNUNET_TESTING_Daemon *d, | ||
1141 | char *service, | ||
1142 | struct GNUNET_TIME_Relative timeout, | ||
1143 | GNUNET_TESTING_NotifyDaemonRunning cb, void *cb_cls) | ||
1144 | { | ||
1145 | char *arg; | ||
1146 | d->cb = cb; | ||
1147 | d->cb_cls = cb_cls; | ||
1148 | |||
1149 | GNUNET_assert(service != NULL); | ||
1150 | GNUNET_assert(d->running == GNUNET_YES); | ||
1151 | GNUNET_assert(d->phase == SP_START_DONE); | ||
1152 | |||
1153 | #if DEBUG_TESTING | ||
1154 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1155 | _("Starting service %s for peer `%4s'\n"), service, GNUNET_i2s (&d->id)); | ||
1156 | #endif | ||
1157 | |||
1158 | d->phase = SP_SERVICE_START; | ||
1159 | |||
1160 | /* Check if this is a local or remote process */ | ||
1161 | if (NULL != d->hostname) | ||
1162 | { | ||
1163 | #if DEBUG_TESTING | ||
1164 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1165 | "Starting gnunet-arm with config `%s' on host `%s'.\n", | ||
1166 | d->cfgfile, d->hostname); | ||
1167 | #endif | ||
1168 | |||
1169 | if (d->username != NULL) | ||
1170 | GNUNET_asprintf (&arg, "%s@%s", d->username, d->hostname); | ||
1171 | else | ||
1172 | arg = GNUNET_strdup (d->hostname); | ||
1173 | |||
1174 | d->proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", | ||
1175 | #if !DEBUG_TESTING | ||
1176 | "-q", | ||
1177 | #endif | ||
1178 | arg, "gnunet-arm", | ||
1179 | #if DEBUG_TESTING | ||
1180 | "-L", "DEBUG", | ||
1181 | #endif | ||
1182 | "-c", d->cfgfile, "-i", service, "-q", | ||
1183 | NULL); | ||
1184 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1185 | "Starting gnunet-arm with command ssh %s gnunet-arm -c %s -i %s -q\n", | ||
1186 | arg, "gnunet-arm", d->cfgfile, service); | ||
1187 | GNUNET_free (arg); | ||
1188 | } | ||
1189 | else | ||
1190 | { | ||
1191 | #if DEBUG_TESTING | ||
1192 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1193 | "Starting gnunet-arm with config `%s' locally.\n", | ||
1194 | d->cfgfile); | ||
1195 | #endif | ||
1196 | d->proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm", | ||
1197 | "gnunet-arm", | ||
1198 | #if DEBUG_TESTING | ||
1199 | "-L", "DEBUG", | ||
1200 | #endif | ||
1201 | "-c", d->cfgfile, "-i", service, "-q", | ||
1202 | NULL); | ||
1203 | } | ||
1204 | |||
1205 | d->max_timeout = GNUNET_TIME_relative_to_absolute (timeout); | ||
1206 | d->task = GNUNET_SCHEDULER_add_now (&start_fsm, d); | ||
1207 | } | ||
1208 | |||
1209 | /** | ||
1135 | * Start a peer that has previously been stopped using the daemon_stop | 1210 | * Start a peer that has previously been stopped using the daemon_stop |
1136 | * call (and files weren't deleted and the allow restart flag) | 1211 | * call (and files weren't deleted and the allow restart flag) |
1137 | * | 1212 | * |