Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Use the Windows _wspawnv() interface with the _P_NOWAIT option to start a separate backoffice process whenever necessary. Add the backoffice-logfile setting for monitoring backoffice operation. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
2583cae18a4bcf03408e3f56544a53de |
User & Date: | drh 2018-08-07 20:11:10 |
Context
2018-08-07
| ||
20:58 | Improved windows code for the backoffice. Properly check to see if processes still exist. Provide a timeout feature. check-in: 43c29877 user: drh tags: trunk | |
20:11 | Use the Windows _wspawnv() interface with the _P_NOWAIT option to start a separate backoffice process whenever necessary. Add the backoffice-logfile setting for monitoring backoffice operation. check-in: 2583cae1 user: drh tags: trunk | |
18:53 | Allow manifest artifacts to omit the C and U cards, because otherwise there are some historical manifest artifacts in Fossil itself that will not parse, and there may be similar artifacts in other repositories. check-in: b3ccc4bf user: drh tags: trunk | |
Changes
Changes to src/backoffice.c.
58
59
60
61
62
63
64
65
66
67
68
69
70
71
...
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
|
** routine. */ #include "config.h" #include "backoffice.h" #include <time.h> #if defined(_WIN32) # include <windows.h> #else # include <unistd.h> # include <sys/types.h> # include <signal.h> #endif /* ................................................................................ } /* ** This routine runs to do the backoffice processing. When adding new ** backoffice processing tasks, add them here. */ void backoffice_work(void){ email_backoffice(0); } /* ** COMMAND: backoffice ** ** Usage: backoffice [-R repository] ** ** Run backoffice processing. This might be done by a cron job or ** similar to make sure backoffice processing happens periodically. */ void backoffice_command(void){ verify_all_options(); db_find_and_open_repository(0,0); backoffice_thread(); } /* ** This is the main interface to backoffice from the rest of the system. ** This routine launches either backoffice_thread() directly or as a ** subprocess. */ void backoffice_run_if_needed(void){ if( backofficeDb==0 ) return; if( strcmp(backofficeDb,"x")==0 ) return; if( g.db ) return; if( g.repositoryOpen ) return; #if !defined(_WIN32) { pid_t pid = fork(); if( pid>0 ){ /* This is the parent in a successful fork(). Return immediately. */ if( g.fAnyTrace ){ fprintf(stderr, "/***** Subprocess %d creates backoffice child %d *****/\n", getpid(), (int)pid); } return; } if( pid==0 ){ /* This is the child of a successful fork(). Run backoffice. */ db_open_repository(backofficeDb); backofficeDb = "x"; backoffice_thread(); db_close(1); if( g.fAnyTrace ){ fprintf(stderr, "/***** Backoffice Child %d exits *****/\n", getpid()); } |
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
...
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
|
** routine. */ #include "config.h" #include "backoffice.h" #include <time.h> #if defined(_WIN32) # include <windows.h> # include <stdio.h> # include <process.h> #else # include <unistd.h> # include <sys/types.h> # include <signal.h> #endif /* ................................................................................ } /* ** This routine runs to do the backoffice processing. When adding new ** backoffice processing tasks, add them here. */ void backoffice_work(void){ /* Log the backoffice run for testing purposes. For production deployments ** the "backoffice-logfile" property should be unset and the following code ** should be a no-op. */ char *zLog = db_get("backoffice-logfile",0); if( zLog && zLog[0] ){ FILE *pLog = fossil_fopen(zLog, "a"); if( pLog ){ char *zDate = db_text(0, "SELECT datetime('now');"); fprintf(pLog, "%s (%d) backoffice running\n", zDate, getpid()); fclose(pLog); } } /* Here is where the actual work of the backoffice happens */ email_backoffice(0); } /* ** COMMAND: backoffice ** ** Usage: backoffice [-R repository] ** ** Run backoffice processing. This might be done by a cron job or ** similar to make sure backoffice processing happens periodically. */ void backoffice_command(void){ if( find_option("trace",0,0)!=0 ) g.fAnyTrace = 1; db_find_and_open_repository(0,0); verify_all_options(); backoffice_thread(); } /* ** This is the main interface to backoffice from the rest of the system. ** This routine launches either backoffice_thread() directly or as a ** subprocess. */ void backoffice_run_if_needed(void){ if( backofficeDb==0 ) return; if( strcmp(backofficeDb,"x")==0 ) return; if( g.db ) return; if( g.repositoryOpen ) return; #if defined(_WIN32) { int i; intptr_t x; char *argv[4]; wchar_t *ax[5]; argv[0] = g.nameOfExe; argv[1] = "backoffice"; argv[2] = "-R"; argv[3] = backofficeDb; ax[4] = 0; for(i=0; i<=3; i++) ax[i] = fossil_utf8_to_unicode(argv[i]); x = _wspawnv(_P_NOWAIT, ax[0], ax); for(i=0; i<=3; i++) fossil_unicode_free(ax[i]); if( g.fAnyTrace ){ fprintf(stderr, "/***** Subprocess %d creates backoffice child %d *****/\n", getpid(), (int)x); } if( x>=0 ) return; } #else /* unix */ { pid_t pid = fork(); if( pid>0 ){ /* This is the parent in a successful fork(). Return immediately. */ if( g.fAnyTrace ){ fprintf(stderr, "/***** Subprocess %d creates backoffice child %d *****/\n", getpid(), (int)pid); } return; } if( pid==0 ){ /* This is the child of a successful fork(). Run backoffice. */ setsid(); db_open_repository(backofficeDb); backofficeDb = "x"; backoffice_thread(); db_close(1); if( g.fAnyTrace ){ fprintf(stderr, "/***** Backoffice Child %d exits *****/\n", getpid()); } |
Changes to src/db.c.
3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 |
*/ /* ** SETTING: backoffice-nodelay boolean default=on ** If backoffice-nodelay is true, then the backoffice processing ** will never invoke sleep(). If it has nothing useful to do, ** it simply exits. */ /* ** SETTING: binary-glob width=40 versionable block-text ** The VALUE of this setting is a comma or newline-separated list of ** GLOB patterns that should be treated as binary files ** for committing and merging purposes. Example: *.jpg */ #if defined(_WIN32)||defined(__CYGWIN__)||defined(__DARWIN__) |
> > > > > > > |
3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 |
*/ /* ** SETTING: backoffice-nodelay boolean default=on ** If backoffice-nodelay is true, then the backoffice processing ** will never invoke sleep(). If it has nothing useful to do, ** it simply exits. */ /* ** SETTING: backoffice-logfile width=40 ** If backoffice-logfile is not an empty string and is a valid ** filename, then a one-line message is appended to that file ** every time the backoffice runs. This can be used for debugging, ** to ensure that backoffice is running appropriately. */ /* ** SETTING: binary-glob width=40 versionable block-text ** The VALUE of this setting is a comma or newline-separated list of ** GLOB patterns that should be treated as binary files ** for committing and merging purposes. Example: *.jpg */ #if defined(_WIN32)||defined(__CYGWIN__)||defined(__DARWIN__) |