]> git.evergreen-ils.org Git - OpenSRF.git/blob - src/libopensrf/opensrf.c
Fixed a bug in the chunking.
[OpenSRF.git] / src / libopensrf / opensrf.c
1 #include "opensrf/osrf_system.h"
2
3 /**
4         @brief Run an OSRF server as defined by the command line and a config file.
5         @param argc Number of command line arguments, plus one.
6         @param argv Ragged array of command name plus command line arguments.
7         @return 0 if successful, or 1 if failure.
8
9         Command line parameters:
10         - Full network name of the host where the process is running; or 'localhost' will do.
11         - Name of the configuration file; normally '/openils/conf/opensrf_core.xml'.
12         - Name of an aggregate within the configuration file, containing the relevant subset
13         of configuration stuff.
14 */
15 int main( int argc, char* argv[] ) {
16
17         if( argc < 4 ) {
18                 fprintf(stderr, "Usage: %s <host> <bootstrap_config> <config_context>\n", argv[0]);
19                 return 1;
20         }
21
22         /* these must be strdup'ed because init_proc_title / set_proc_title
23                 are evil and overwrite the argv memory */
24         char* host      = strdup( argv[1] );
25         char* config    = strdup( argv[2] );
26         char* context   = strdup( argv[3] );
27
28         if( argv[4] )
29                 osrfSystemSetPidFile( argv[4] );
30
31         init_proc_title( argc, argv );
32         set_proc_title( "OpenSRF System-C" );
33
34         int ret = osrfSystemBootstrap( host, config, context );
35
36         if (ret != 0) {
37                 osrfLogError(
38                         OSRF_LOG_MARK,
39                         "Server Loop returned an error condition, exiting with %d",
40                         ret
41                 );
42         }
43
44         free(host);
45         free(config);
46         free(context);
47
48         return ret;
49 }
50
51