24 #define SYNC_STATE_STARTED "started"
25 #define SYNC_STATE_FINISHED "finished"
28 bool sync_reached =
false;
34 while (!sync_reached && !error) {
37 if (show_serve_error.
passed()) {
39 fprintf(stderr,
"Error serving DB (while waiting for sync '%s'): %s\n", sync_id, serve_error);
48 fprintf(stderr,
"reached expected sync on ID '%s': current value is '%s'\n", sync_id, value);
52 error =
GBS_global_string(
"sync-ID '%s' has unexpected value '%s'", sync_id, value);
56 fprintf(stderr,
"waiting for sync on ID '%s': current value is '%s'\n", sync_id, value);
79 char *sync_via_ID =
NULp;
81 if (!background && requires_DB_access) {
83 static int sync_counter = 0;
89 fprintf(stderr,
"synchronise command using ID '%s'. command=%s\n", sync_via_ID, cmd);
108 bash_command.
cat(
"LD_LIBRARY_PATH=");
111 bash_command.
cat(dquoted_library_path);
112 free(dquoted_library_path);
114 bash_command.
cat(
";export LD_LIBRARY_PATH;");
120 bash_command.
cat(
"echo 'Warning: LD_LIBRARY_PATH is undefined';");
124 bash_command.
cat(
" (");
125 bash_command.
cat(cmd);
129 const char *wait_commands = hidden ?
"sleep 1" :
"echo; echo 'Press ENTER to close this window'; read a";
131 if (always_wait_key) {
132 bash_command.
cat(
"; [ $? -ne 0 ] && echo \"Command terminated with failure (exit code $?)\"");
133 bash_command.
cat(
"; ");
136 bash_command.
cat(
"; xc=$?");
138 bash_command.
cat(
"; ");
139 bash_command.
cat(sync_command);
141 bash_command.
cat(
"; [ $xc -ne 0 ] && echo \"Command terminated with failure (exit code $xc)\"");
142 bash_command.
cat(
"; exit $xc");
143 bash_command.
cat(
") || (");
145 bash_command.
cat(wait_commands);
146 if (always_wait_key && sync_command) {
147 bash_command.
cat(
"; ");
148 bash_command.
cat(sync_command);
150 bash_command.
put(
')');
156 system_call.
cat(
" bash -c ");
157 system_call.
cat(squoted_bash_command);
158 free(squoted_bash_command);
160 system_call.
cat(
" )");
161 if (background) system_call.
cat(
" &");
174 if (sync_via_ID && !error) {
178 freenull(sync_via_ID);
GB_ERROR GBK_system(const char *system_command)
bool GB_is_server(GBDATA *gbd)
char * GBK_doublequote(const char *arg)
const char * GBS_global_string(const char *templat,...)
void cat(const char *from)
GB_ERROR ARB_system(const char *cmd, XCmdType boundExectype)
GB_ERROR GB_await_error()
GB_ERROR serve_db_while_GUI_is_blocked(GBDATA *gb_main)
static void error(const char *msg)
GB_CSTR GB_read_sync_value(GBDATA *gb_main, const char *id)
GB_ERROR GB_write_sync_value(GBDATA *gb_main, const char *id, const char *value)
#define SYNC_STATE_FINISHED
void ARB_system_in_console_cb(AW_window *, const char *command, const XCmdType *exectype)
GB_CSTR GB_getenv(const char *env)
char * GBK_singlequote(const char *arg)
void restart(double factor)
static GB_ERROR wait_for_sync__servingDB(GBDATA *gb_main, const char *sync_id)
const char * get_data() const
GBDATA * get_gb_main() const
GB_transaction ta(gb_var)
XCMD_TYPE get_type() const
GB_CSTR GB_getenvARB_XCMD(void)
void aw_message_if(GB_ERROR error)
char * GBS_global_string_copy(const char *templat,...)
#define SYNC_STATE_STARTED