00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include "sm_vas.h"
00035
00036
00037
00038
00039
00040
00041
00042 class smthread_user_t : public smthread_t {
00043 int argc;
00044 char **argv;
00045 public:
00046 int retval;
00047
00048 smthread_user_t(int ac, char **av)
00049 : smthread_t(t_regular, "smthread_user_t"),
00050 argc(ac), argv(av), retval(0) { }
00051 ~smthread_user_t() {}
00052 void run() {
00053 cout << "Starting SSM and performing recovery ..." << endl;
00054 ss_m* ssm = new ss_m();
00055 if (!ssm) {
00056 cerr << "Error: Out of memory for ss_m" << endl;
00057 retval = 1;
00058 return;
00059 }
00060
00061
00062
00063
00064
00065
00066
00067 delete ssm;
00068 ssm = NULL;
00069 }
00070 };
00071
00072
00073 int
00074 main(int argc, char* argv[])
00075 {
00076
00077
00078
00079 option_group_t options(3);
00080 W_COERCE(options.add_class_level("startstop"));
00081 W_COERCE(options.add_class_level("server"));
00082 W_COERCE(options.add_class_level(argv[0]));
00083
00084
00085 W_COERCE(ss_m::setup_options(&options));
00086
00087
00088 {
00089
00090
00091
00092
00093 w_ostrstream err_stream;
00094 const char* opt_file = "EXAMPLE_SHORECONFIG";
00095 option_file_scan_t opt_scan(opt_file, &options);
00096
00097
00098
00099 w_rc_t rc = opt_scan.scan(true , err_stream, true);
00100 if (rc.is_error()) {
00101 cerr << "Error in reading option file: " << opt_file << endl;
00102 cerr << "\t" << err_stream.c_str() << endl;
00103 return 1;
00104 }
00105 }
00106 {
00107
00108 w_ostrstream err_stream;
00109 w_rc_t rc = options.check_required(&err_stream);
00110 if (rc.is_error()) {
00111 cerr << "These required options are not set:" << endl;
00112 cerr << err_stream.c_str() << endl;
00113 return 1;
00114 }
00115 }
00116
00117
00118 smthread_user_t *smtu = new smthread_user_t(argc, argv);
00119 if (!smtu)
00120 W_FATAL(fcOUTOFMEMORY);
00121
00122 w_rc_t e = smtu->fork();
00123 if(e.is_error()) {
00124 cerr << "error forking thread: " << e <<endl;
00125 return 1;
00126 }
00127 e = smtu->join();
00128 if(e.is_error()) {
00129 cerr << "error forking thread: " << e <<endl;
00130 return 1;
00131 }
00132 int rv = smtu->retval;
00133 delete smtu;
00134 return rv;
00135 }
00136