mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	Make the classes that get started by jsvc implement Daemon.
Set the daemon version centrally in the pom
This commit is contained in:
		
							parent
							
								
									c2118180d5
								
							
						
					
					
						commit
						dcc288c8be
					
				| @ -36,6 +36,11 @@ | |||||||
|       <artifactId>cloud-utils</artifactId> |       <artifactId>cloud-utils</artifactId> | ||||||
|       <version>${project.version}</version> |       <version>${project.version}</version> | ||||||
|     </dependency> |     </dependency> | ||||||
|  |     <dependency> | ||||||
|  |         <groupId>commons-daemon</groupId> | ||||||
|  |         <artifactId>commons-daemon</artifactId> | ||||||
|  |         <version>${cs.daemon.version}</version> | ||||||
|  |     </dependency>     | ||||||
|   </dependencies> |   </dependencies> | ||||||
|   <build> |   <build> | ||||||
|     <defaultGoal>install</defaultGoal> |     <defaultGoal>install</defaultGoal> | ||||||
|  | |||||||
| @ -38,6 +38,9 @@ import java.util.UUID; | |||||||
| 
 | 
 | ||||||
| import javax.naming.ConfigurationException; | import javax.naming.ConfigurationException; | ||||||
| 
 | 
 | ||||||
|  | import org.apache.commons.daemon.Daemon; | ||||||
|  | import org.apache.commons.daemon.DaemonContext; | ||||||
|  | import org.apache.commons.daemon.DaemonInitException; | ||||||
| import org.apache.commons.httpclient.HttpClient; | import org.apache.commons.httpclient.HttpClient; | ||||||
| import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; | import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; | ||||||
| import org.apache.commons.httpclient.methods.GetMethod; | import org.apache.commons.httpclient.methods.GetMethod; | ||||||
| @ -58,7 +61,7 @@ import com.cloud.utils.backoff.impl.ConstantTimeBackoff; | |||||||
| import com.cloud.utils.exception.CloudRuntimeException; | import com.cloud.utils.exception.CloudRuntimeException; | ||||||
| import com.cloud.utils.script.Script; | import com.cloud.utils.script.Script; | ||||||
| 
 | 
 | ||||||
| public class AgentShell implements IAgentShell { | public class AgentShell implements IAgentShell, Daemon { | ||||||
|     private static final Logger s_logger = Logger.getLogger(AgentShell.class |     private static final Logger s_logger = Logger.getLogger(AgentShell.class | ||||||
|             .getName()); |             .getName()); | ||||||
|     private static final MultiThreadedHttpConnectionManager s_httpClientManager = new MultiThreadedHttpConnectionManager(); |     private static final MultiThreadedHttpConnectionManager s_httpClientManager = new MultiThreadedHttpConnectionManager(); | ||||||
| @ -377,6 +380,16 @@ public class AgentShell implements IAgentShell { | |||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|      |      | ||||||
|  |     @Override | ||||||
|  |     public void init(DaemonContext dc) throws DaemonInitException { | ||||||
|  |         s_logger.debug("Initializing AgentShell from JSVC"); | ||||||
|  |         try { | ||||||
|  |             init(dc.getArguments()); | ||||||
|  |         } catch (ConfigurationException ex) { | ||||||
|  |             throw new DaemonInitException("Initialization failed", ex); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |      | ||||||
|     public void init(String[] args) throws ConfigurationException { |     public void init(String[] args) throws ConfigurationException { | ||||||
| 
 | 
 | ||||||
|     	// PropertiesUtil is used both in management server and agent packages, |     	// PropertiesUtil is used both in management server and agent packages, | ||||||
| @ -629,6 +642,7 @@ public class AgentShell implements IAgentShell { | |||||||
| 
 | 
 | ||||||
|     public static void main(String[] args) { |     public static void main(String[] args) { | ||||||
|         try { |         try { | ||||||
|  |             s_logger.debug("Initializing AgentShell from main"); | ||||||
|             AgentShell shell = new AgentShell(); |             AgentShell shell = new AgentShell(); | ||||||
|             shell.init(args); |             shell.init(args); | ||||||
|             shell.start(); |             shell.start(); | ||||||
| @ -636,4 +650,5 @@ public class AgentShell implements IAgentShell { | |||||||
|             System.out.println(e.getMessage()); |             System.out.println(e.getMessage()); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										1
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								pom.xml
									
									
									
									
									
								
							| @ -84,6 +84,7 @@ | |||||||
|     <cs.replace.properties>build/replace.properties</cs.replace.properties> |     <cs.replace.properties>build/replace.properties</cs.replace.properties> | ||||||
|     <cs.libvirt-java.version>0.4.9</cs.libvirt-java.version> |     <cs.libvirt-java.version>0.4.9</cs.libvirt-java.version> | ||||||
|     <cs.target.dir>target</cs.target.dir> |     <cs.target.dir>target</cs.target.dir> | ||||||
|  |     <cs.daemon.version>1.0.10</cs.daemon.version> | ||||||
|   </properties> |   </properties> | ||||||
| 
 | 
 | ||||||
|   <distributionManagement> |   <distributionManagement> | ||||||
|  | |||||||
| @ -40,7 +40,7 @@ | |||||||
|     <dependency> |     <dependency> | ||||||
|     	<groupId>commons-daemon</groupId> |     	<groupId>commons-daemon</groupId> | ||||||
|     	<artifactId>commons-daemon</artifactId> |     	<artifactId>commons-daemon</artifactId> | ||||||
|     	<version>1.0.10</version> |     	<version>${cs.daemon.version}</version> | ||||||
|     </dependency> |     </dependency> | ||||||
|   </dependencies> |   </dependencies> | ||||||
|   <build> |   <build> | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user