1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the License). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/CDDL.txt 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/CDDL.txt. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets [] replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 * 26 */ 27 28 #pragma ident "@(#)wls_svc_start.c 1.7 07/06/06 SMI" 29 30 /* 31 * wls_svc_start.c - Start method for BEA WebLogic Server 32 */ 33 34 #include <rgm/libdsdev.h> 35 #include "wls.h" 36 37 /* Percentage of start/probe timeout for the DB probe */ 38 #define DB_PROBE_TIMEOUT_PCT 25 39 40 /* 41 * The start method for BEA WebLogic Server. Does some sanity checks on 42 * the resource settings and then starts the WLS under PMF with 43 * an action script. 44 */ 45 46 int 47 main(int argc, char *argv[]) 48 { 49 bea_extn_props_t beaextnprops; 50 scds_handle_t scds_handle; 51 int rc; 52 int svc_start_timeout, db_probe_timeout; 53 char *rsname = NULL, *rgname = NULL; 54 55 /* 56 * Process all the arguments that have been passed to us from RGM 57 * and do some initialization for syslog 58 */ 59 60 if (scds_initialize(&scds_handle, argc, argv) != SCHA_ERR_NOERR) { 61 return (1); 62 } 63 64 /* Get resource and resource group names */ 65 rsname = (char *)scds_get_resource_name(scds_handle); 66 rgname = (char *)scds_get_resource_group_name(scds_handle); 67 68 /* Get the extension properties */ 69 70 if (get_wls_extn_props(scds_handle, &beaextnprops, B_FALSE) != 0) { 71 scds_syslog(LOG_ERR, 72 "Failed to retrieve WLS extension properties."); 73 rc = 1; 74 goto finished; 75 } 76 77 78 /* Validate the configuration and if there is an error return back */ 79 rc = svc_validate(scds_handle, &beaextnprops, B_FALSE); 80 81 if (rc != 0) { 82 scds_syslog(LOG_ERR, 83 "Failed to validate configuration."); 84 goto finished; 85 } 86 87 /* 88 * Before starting the WLS check if the DB is UP. If the DB is 89 * not UP return 0 (so that the start method does not fail). 90 * The probe method will wait till the DB is up and start the 91 * WebLogic Server. 92 */ 93 svc_start_timeout = scds_get_rs_start_timeout(scds_handle); 94 db_probe_timeout = (svc_start_timeout * DB_PROBE_TIMEOUT_PCT) /100; 95 96 rc = probe_db(scds_handle, beaextnprops.db_probe_script, 97 db_probe_timeout); 98 if (rc != 0) { 99 /* 100 * SCMSGS 101 * @explanation 102 * The Data base probe (set in the extension property 103 * db_probe_script) failed. The start method will not start 104 * the WLS. The probe method will wait till the DB probe 105 * succeeds before starting the WLS. 106 * @user_action 107 * Make sure the DB probe (set in db_probe_script) succeeds. 108 * Once the DB is started the WLS probe will start the WLS 109 * instance. 110 */ 111 scds_syslog(LOG_ERR, "The Data base probe %s failed." 112 "The WLS probe will wait for the DB to be UP before " 113 "starting the WLS", beaextnprops.db_probe_script); 114 rc = DB_NOT_AVAILABLE; 115 goto finished; 116 } 117 118 /* Start the data service, if it fails return with an error */ 119 rc = svc_start(scds_handle, &beaextnprops); 120 if (rc != 0) { 121 goto finished; 122 } 123 124 /* Wait for the service to start up fully */ 125 rc = svc_wait(scds_handle, &beaextnprops); 126 scds_syslog_debug(DBG_LEVEL_HIGH, "Returned from svc_wait"); 127 128 129 finished: 130 131 if (rc == SCHA_ERR_NOERR) { 132 (void) scha_resource_setstatus(rsname, rgname, 133 SCHA_RSSTATUS_OK, "Completed successfully."); 134 } else if (rc == DB_NOT_AVAILABLE) { 135 (void) scha_resource_setstatus(rsname, rgname, 136 SCHA_RSSTATUS_DEGRADED, 137 "Database not available."); 138 /* 139 * we dont want to fail the start method if the DB is 140 * not available. We let the probe handle the starting 141 * of the WLS. Set rc to 0; 142 */ 143 rc = 0; 144 } else { 145 (void) scha_resource_setstatus(rsname, rgname, 146 SCHA_RSSTATUS_FAULTED, 147 "Failed to start the WLS."); 148 } 149 150 /* Free up the Environment resources that were allocated */ 151 scds_close(&scds_handle); 152 153 return (rc); 154 } 155