Home | History | Annotate | Download | only in apache
      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  * apache_svc_start.c - Start method for highly available apache
     27  */
     28 
     29 #pragma ident	"@(#)apache_svc_start.c	1.26	07/06/06 SMI"
     30 
     31 #include <rgm/libdsdev.h>
     32 #include "apache.h"
     33 
     34 /*
     35  * The start method for apache. Does some sanity checks on
     36  * the resource settings then starts the apache under PMF with
     37  * an action script.
     38  */
     39 
     40 int
     41 main(int argc, char *argv[])
     42 {
     43 	scds_handle_t		scds_handle;
     44 	int			rc;
     45 
     46 	/*
     47 	 * Process all the arguments that have been passed to us from RGM
     48 	 * and do some initialization for syslog
     49 	 */
     50 
     51 	if (scds_initialize(&scds_handle, argc, argv) != SCHA_ERR_NOERR) {
     52 		return (1);
     53 	}
     54 
     55 	/* Validate the configuration and if there is an error return back */
     56 	rc = svc_validate(scds_handle, B_FALSE);
     57 	if (rc != 0) {
     58 		/*
     59 		 * SCMSGS
     60 		 * @explanation
     61 		 * The data service is not properly configured.
     62 		 * @user_action
     63 		 * Look at the prior syslog messages for specific problems and
     64 		 * take corrective action.
     65 		 */
     66 		scds_syslog(LOG_ERR,
     67 			"Failed to validate configuration.");
     68 		goto finished;
     69 	}
     70 
     71 	/* Start the data service, if it fails return with an error */
     72 	rc = svc_start(scds_handle);
     73 	if (rc != 0) {
     74 		goto finished;
     75 	}
     76 
     77 	scds_syslog_debug(DBG_LEVEL_HIGH,
     78 		"Done with svc_start, calling svc_wait.");
     79 
     80 	/* Wait for the service to start up fully */
     81 	rc = svc_wait(scds_handle);
     82 	scds_syslog_debug(DBG_LEVEL_HIGH,
     83 		"Done with svc_wait which returned <%d>.", rc);
     84 
     85 finished:
     86 	/* Free up the Environment resources that were allocated */
     87 	scds_close(&scds_handle);
     88 
     89 	return (rc);
     90 }
     91