|
1
|
|
|
<?php |
|
2
|
|
|
namespace Kunstmaan\Skylab\Skeleton; |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* ApacheSkeleton |
|
6
|
|
|
*/ |
|
7
|
|
|
class TomcatSkeleton extends AbstractSkeleton |
|
8
|
|
|
{ |
|
9
|
|
|
|
|
10
|
|
|
const NAME = "tomcat"; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @return string |
|
14
|
|
|
*/ |
|
15
|
|
|
public function getName() |
|
16
|
|
|
{ |
|
17
|
|
|
return self::NAME; |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @param \ArrayObject $project |
|
22
|
|
|
* |
|
23
|
|
|
* @return mixed |
|
24
|
|
|
*/ |
|
25
|
|
|
public function create(\ArrayObject $project) |
|
26
|
|
|
{ |
|
27
|
|
|
$tempFilename = sys_get_temp_dir() . '/apache-tomcat-7.0.61-temp.tar.gz'; |
|
28
|
|
|
$this->dialogProvider->logCommand("Downloading Tomcat to $tempFilename"); |
|
29
|
|
|
$this->remoteProvider->curl("http://apache.cu.be/tomcat/tomcat-7/v7.0.61/bin/apache-tomcat-7.0.61.tar.gz", "application/x-gzip", $tempFilename); |
|
30
|
|
|
$this->fileSystemProvider->createDirectory($project, 'tomcat'); |
|
31
|
|
|
$tomcatFolder = $this->fileSystemProvider->getProjectDirectory($project["name"]) . 'tomcat'; |
|
32
|
|
|
$this->processProvider->executeSudoCommand("tar xvf " . $tempFilename . ' -C ' . $tomcatFolder); |
|
33
|
|
|
|
|
34
|
|
|
$this->fileSystemProvider->render( |
|
35
|
|
|
"/tomcat/apache.d/32tomcat.conf.twig", |
|
36
|
|
|
$this->fileSystemProvider->getProjectConfigDirectory($project["name"]) . "/apache.d/32tomcat", |
|
37
|
|
|
array() |
|
38
|
|
|
); |
|
39
|
|
|
$this->processProvider->executeSudoCommand("ln -sf " . $this->fileSystemProvider->getProjectDirectory($project["name"]) . 'tomcat/* ' . $this->fileSystemProvider->getProjectDirectory($project["name"]).'tomcat/default'); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @return mixed |
|
44
|
|
|
*/ |
|
45
|
|
|
public function preMaintenance() |
|
46
|
|
|
{ |
|
47
|
|
|
// TODO: Implement preMaintenance() method. |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @return mixed |
|
52
|
|
|
*/ |
|
53
|
|
|
public function postMaintenance() |
|
54
|
|
|
{ |
|
55
|
|
|
$workerlist = array(); |
|
56
|
|
|
$workers = array(); |
|
57
|
|
|
$this->fileSystemProvider->projectsLoop(function ($project) use (&$workerlist, &$workers) { |
|
58
|
|
|
$webxmlfile = $project["dir"].'/tomcat/default/conf/server.xml'; |
|
59
|
|
|
if (file_exists($webxmlfile)) { |
|
60
|
|
|
$workerlist[] = $project['name']; |
|
61
|
|
|
$xml = simplexml_load_string($this->processProvider->executeSudoCommand("cat " . $webxmlfile)); |
|
62
|
|
|
$connector = $xml->xpath('/Server/Service/Connector/@port'); |
|
63
|
|
|
$port = $connector[0]->port->__toString(); |
|
64
|
|
|
$workers[] = 'worker.'.$project['name'].'.type=ajp13'; |
|
65
|
|
|
$workers[] = 'worker.'.$project['name'].'.host=localhost'; |
|
66
|
|
|
$workers[] = 'worker.'.$project['name'].'.port='.$port; |
|
67
|
|
|
$workers[] = ''; |
|
68
|
|
|
} |
|
69
|
|
|
}); |
|
70
|
|
|
array_unshift($workers, 'worker.list='.implode(',', $workerlist)); |
|
71
|
|
|
$this->fileSystemProvider->writeProtectedFile($this->app["config"]["tomcat"]["workerspath"], implode("\n", $workers)); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @param \ArrayObject $project |
|
76
|
|
|
* |
|
77
|
|
|
* @return mixed |
|
78
|
|
|
*/ |
|
79
|
|
|
public function maintenance(\ArrayObject $project) |
|
80
|
|
|
{ |
|
81
|
|
|
// TODO: Implement maintenance() method. |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @param \ArrayObject $project |
|
86
|
|
|
* |
|
87
|
|
|
* @return mixed |
|
88
|
|
|
*/ |
|
89
|
|
|
public function preBackup(\ArrayObject $project) |
|
90
|
|
|
{ |
|
91
|
|
|
// TODO: Implement preBackup() method. |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* @param \ArrayObject $project |
|
96
|
|
|
* |
|
97
|
|
|
* @return mixed |
|
98
|
|
|
*/ |
|
99
|
|
|
public function postBackup(\ArrayObject $project) |
|
100
|
|
|
{ |
|
101
|
|
|
// TODO: Implement postBackup() method. |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @param \ArrayObject $project |
|
106
|
|
|
* |
|
107
|
|
|
* @return mixed |
|
108
|
|
|
*/ |
|
109
|
|
|
public function preRemove(\ArrayObject $project) |
|
110
|
|
|
{ |
|
111
|
|
|
// TODO: Implement preRemove() method. |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* @param \ArrayObject $project |
|
116
|
|
|
* |
|
117
|
|
|
* @return mixed |
|
118
|
|
|
*/ |
|
119
|
|
|
public function postRemove(\ArrayObject $project) |
|
120
|
|
|
{ |
|
121
|
|
|
// TODO: Implement postRemove() method. |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* @return string[] |
|
126
|
|
|
*/ |
|
127
|
|
|
public function dependsOn() |
|
128
|
|
|
{ |
|
129
|
|
|
return array("base", "apache", "monitoring"); |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
} |
|
133
|
|
|
|