Commit 293ffec7 293ffec79a0692d26d70cd531ef8e54b583fde4d by root

save

1 parent 6b9889c5
Showing 48 changed files with 759 additions and 76 deletions
...@@ -136,7 +136,7 @@ ...@@ -136,7 +136,7 @@
136 <dependency> 136 <dependency>
137 <groupId>org.emercit</groupId> 137 <groupId>org.emercit</groupId>
138 <artifactId>utilstools</artifactId> 138 <artifactId>utilstools</artifactId>
139 <version>1.12</version> 139 <version>1.13</version>
140 </dependency> 140 </dependency>
141 141
142 </dependencies> 142 </dependencies>
......
1 528d24e7e4a499f3ffd53b20f37c1d6e
...\ No newline at end of file ...\ No newline at end of file
1 04c21c2a5e86f843cd60cd939caee1a12d5f75b4
...\ No newline at end of file ...\ No newline at end of file
1 <?xml version="1.0" encoding="UTF-8"?>
2 <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4 <modelVersion>4.0.0</modelVersion>
5 <groupId>org.emercit</groupId>
6 <artifactId>utilstools</artifactId>
7 <version>1.13</version>
8 </project>
1 325bd099aab6e30e723421fc3c92c960
...\ No newline at end of file ...\ No newline at end of file
1 d1c45642f5e1014728ded0025f0637168d3fa5ee
...\ No newline at end of file ...\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
3 <groupId>org.emercit</groupId> 3 <groupId>org.emercit</groupId>
4 <artifactId>utilstools</artifactId> 4 <artifactId>utilstools</artifactId>
5 <versioning> 5 <versioning>
6 <release>1.12</release> 6 <release>1.13</release>
7 <versions> 7 <versions>
8 <version>1.0</version> 8 <version>1.0</version>
9 <version>1.1</version> 9 <version>1.1</version>
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
18 <version>1.10</version> 18 <version>1.10</version>
19 <version>1.11</version> 19 <version>1.11</version>
20 <version>1.12</version> 20 <version>1.12</version>
21 <version>1.13</version>
21 </versions> 22 </versions>
22 <lastUpdated>20150730124043</lastUpdated> 23 <lastUpdated>20150730153808</lastUpdated>
23 </versioning> 24 </versioning>
24 </metadata> 25 </metadata>
......
1 783d946983428dd9e3aa55dbcc953fce
...\ No newline at end of file ...\ No newline at end of file
1 f720592af8e70c58b6c262c92ae2c999
...\ No newline at end of file ...\ No newline at end of file
......
1 916946b4b7029a982ce5dfcef1f086ac89c62019
...\ No newline at end of file ...\ No newline at end of file
1 41e1fbb03c75906bcff785a016afcbc4b0cb5661
...\ No newline at end of file ...\ No newline at end of file
......
1 package org.emercit.devtools.app;
2
3
4 import java.util.Locale;
5
6 import org.slf4j.Logger;
7 import org.slf4j.LoggerFactory;
8 import org.springframework.web.bind.annotation.RequestMapping;
9 import org.springframework.web.bind.annotation.RequestMethod;
10 import org.springframework.beans.factory.annotation.Autowired;
11
12 import javax.servlet.http.*;
13 import javax.servlet.ServletContext;
14
15 import java.io.*;
16
17 import org.springframework.stereotype.Controller;
18 import org.springframework.validation.BindingResult;
19 import org.springframework.web.bind.annotation.ModelAttribute;
20 import org.springframework.web.bind.annotation.PathVariable;
21 import org.springframework.web.bind.annotation.ResponseBody;
22 import org.springframework.web.bind.annotation.RequestBody;
23 import java.util.Vector;
24 import java.util.ArrayList;
25 import java.util.List;
26 import org.emercit.utilstools.config.Msg;
27 import org.emercit.utilstools.config.MsgResult;
28
29 import org.emercit.devtools.service.SvService;
30
31 import org.emercit.svmanager.model.SvBean;
32
33 @Controller
34 @RequestMapping("api")
35 public class SvController {
36
37
38 @RequestMapping(value = "sv/all", method = RequestMethod.GET)
39 public @ResponseBody Vector<SvBean> getAllSv() {
40
41 return SvService.INSTANCE.getSvBeans();
42 }
43
44 @RequestMapping(value="sv/update" , method = RequestMethod.POST)
45 public @ResponseBody MsgResult update(@RequestBody SvBean bean) {
46
47 return Msg.getMsgResultByCode(SvService.INSTANCE.Update(bean));
48 }
49
50 @RequestMapping(value="sv/start" , method = RequestMethod.POST)
51 public @ResponseBody MsgResult start(@RequestBody SvBean bean) {
52
53 return Msg.getMsgResultByCode(SvService.INSTANCE.Start(bean));
54 }
55
56 @RequestMapping(value="sv/stop" , method = RequestMethod.POST)
57 public @ResponseBody MsgResult stop(@RequestBody SvBean bean) {
58
59 return Msg.getMsgResultByCode(SvService.INSTANCE.Stop(bean));
60 }
61
62 @RequestMapping(value="sv/restart" , method = RequestMethod.POST)
63 public @ResponseBody MsgResult restart(@RequestBody SvBean bean) {
64
65 return Msg.getMsgResultByCode(SvService.INSTANCE.Restart(bean));
66 }
67
68 }
1 package org.emercit.devtools.service; 1 package org.emercit.devtools.service;
2 import org.emercit.model.IPAddressValidator; 2 import org.emercit.model.IPAddressValidator;
3
3 import java.util.Vector; 4 import java.util.Vector;
5
4 import org.emercit.svmanager.service.Sv; 6 import org.emercit.svmanager.service.Sv;
5 import org.emercit.svmanager.service.SvControl; 7 import org.emercit.svmanager.service.SvControl;
6 import org.emercit.svmanager.model.SvBean; 8 import org.emercit.svmanager.model.SvBean;
9
7 import java.util.Vector; 10 import java.util.Vector;
8 11
9 import org.emercit.pckutils.checkservice.STService; 12 import org.emercit.pckutils.checkservice.STService;
...@@ -30,7 +33,7 @@ public enum SvService { ...@@ -30,7 +33,7 @@ public enum SvService {
30 */ 33 */
31 public Vector<SvBean> getSvBeans() { 34 public Vector<SvBean> getSvBeans() {
32 35
33 svbeans=new Vector<SvBean>(); 36 svbeans=sv.get();
34 37
35 for (SvBean s:svbeans) { // проверяем запущен или остановлен 38 for (SvBean s:svbeans) { // проверяем запущен или остановлен
36 try { s.setIsrun(st.IsRun(s.getProcess())); } catch (Exception e) {}; 39 try { s.setIsrun(st.IsRun(s.getProcess())); } catch (Exception e) {};
...@@ -42,24 +45,29 @@ public enum SvService { ...@@ -42,24 +45,29 @@ public enum SvService {
42 /* 45 /*
43 * 46 *
44 */ 47 */
45 public int Update(Vector<SvBean> beans) { 48 public int Update(SvBean bean) {
46 49
47 return sv.set(beans); 50 svbeans=sv.get();
51
52 for (SvBean b:svbeans) {
53
54 if (b.getId()==bean.getId()) {
55 b.setAutostart(bean.getAutostart());
56 }
57 }
58 return sv.set(svbeans);
48 } 59 }
49 60
50 public int Start(SvBean svbean) { 61 public int Start(SvBean svbean) {
51
52 svcontrol=new SvControl(svbean.getProcess()); 62 svcontrol=new SvControl(svbean.getProcess());
53 return svcontrol.start(); 63 return svcontrol.start();
54 } 64 }
55 65
56 public int Stop(SvBean svbean) { 66 public int Stop(SvBean svbean) {
57
58 svcontrol=new SvControl(svbean.getProcess()); 67 svcontrol=new SvControl(svbean.getProcess());
59 return svcontrol.stop(); 68 return svcontrol.stop();
60 } 69 }
61 70
62
63 public int Restart(SvBean svbean) { 71 public int Restart(SvBean svbean) {
64 svcontrol=new SvControl(svbean.getProcess()); 72 svcontrol=new SvControl(svbean.getProcess());
65 return svcontrol.restart(); 73 return svcontrol.restart();
......
...@@ -61,12 +61,34 @@ ...@@ -61,12 +61,34 @@
61 61
62 62
63 63
64 .fieladtime { 64
65 background-image:none; 65
66 background-color:#FFFFCC; 66 .button-green
67 color:red; 67 {
68 background:url(resources/img/button-green.png) 16px no-repeat !important;
69 }
70
71 .button-orange
72 {
73 background:url(resources/img/button-green.png) 16px no-repeat !important;
74 }
75 .button-red
76 {
77 background:url(resources/img/button-red.png) 16px no-repeat !important;
78 }
79
80 .button-white
81 {
82 background:url(img/button-white.png) 20px no-repeat !important;
83 }
84
85
86 .fieladtime {
87 background-image:none;
88 background-color:#FFFFCC;
89 color:red;
68 90
69 } 91 }
70 92
71 93
72 </style> 94 </style>
......

2.53 KB | W: | H:

2.53 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin

1.21 KB | W: | H:

1.21 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin

2.86 KB | W: | H:

2.86 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin

805 Bytes | W: | H:

805 Bytes | W: | H:

  • 2-up
  • Swipe
  • Onion skin

1.46 KB | W: | H:

1.46 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin

3.24 KB | W: | H:

3.24 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin

5.78 KB | W: | H:

5.78 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin

3.08 KB | W: | H:

3.08 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin

988 Bytes | W: | H:

988 Bytes | W: | H:

  • 2-up
  • Swipe
  • Onion skin

688 Bytes | W: | H:

688 Bytes | W: | H:

  • 2-up
  • Swipe
  • Onion skin

489 Bytes | W: | H:

489 Bytes | W: | H:

  • 2-up
  • Swipe
  • Onion skin

1.08 KB | W: | H:

1.08 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin

686 Bytes | W: | H:

686 Bytes | W: | H:

  • 2-up
  • Swipe
  • Onion skin

731 Bytes | W: | H:

731 Bytes | W: | H:

  • 2-up
  • Swipe
  • Onion skin
1 Ext.application({ 1 Ext.application({
2 name : 'App', 2 name : 'App',
3 globals:{
4 serverNotFound:'Сервер конфигурации недоступен',
5 Error:'Ошибка'
6
7
8 },
9
3 appFolder:"resources/js/app", 10 appFolder:"resources/js/app",
4 views : [ 11 views : [
5 'MainConfig', 12 'MainConfig',
...@@ -13,7 +20,8 @@ Ext.application({ ...@@ -13,7 +20,8 @@ Ext.application({
13 'DetailProxy', 20 'DetailProxy',
14 'RemoteServer', 21 'RemoteServer',
15 'DeviceControl', 22 'DeviceControl',
16 'Log' 23 'Log',
24 'Sv'
17 25
18 26
19 27
...@@ -27,14 +35,16 @@ Ext.application({ ...@@ -27,14 +35,16 @@ Ext.application({
27 'Proxy', 35 'Proxy',
28 'RemoteServer', 36 'RemoteServer',
29 'DeviceControl', 37 'DeviceControl',
30 'Log' 38 'Log',
39 'Sv'
31 40
32 41
33 ], 42 ],
34 43
35 stores : [ 44 stores : [
36 'Eth', 45 'Eth',
37 'Dns' 46 'Dns',
47 'Sv'
38 48
39 ], 49 ],
40 50
...@@ -164,16 +174,12 @@ Ext.application({ ...@@ -164,16 +174,12 @@ Ext.application({
164 174
165 { 175 {
166 title: 'DNS', 176 title: 'DNS',
167 items:[ 177 items:[ {
168
169 {
170 xtype : 'mvvm-DnsView', 178 xtype : 'mvvm-DnsView',
171 id:'grdDns', 179 id:'grdDns',
172 name:'grdDns' 180 name:'grdDns'
173 181
174 } 182 }]
175
176 ]
177 }, 183 },
178 184
179 185
...@@ -217,6 +223,13 @@ Ext.application({ ...@@ -217,6 +223,13 @@ Ext.application({
217 region: 'center', 223 region: 'center',
218 xtype: 'tabpanel', 224 xtype: 'tabpanel',
219 items: [ 225 items: [
226
227 {
228 xtype : 'mvvm-SvView',
229 id:'grdSv',
230 name:'grdSv'
231
232 }
220 233
221 ] 234 ]
222 235
...@@ -225,6 +238,24 @@ Ext.application({ ...@@ -225,6 +238,24 @@ Ext.application({
225 }, 238 },
226 239
227 { 240 {
241 title: 'НАСТРОЙКИ В XML',
242 items:[
243 {
244 region: 'center',
245 xtype: 'tabpanel',
246 items: [
247
248 ]
249
250 }
251 ]
252 },
253
254
255
256
257
258 {
228 title: 'ЖУРНАЛ', 259 title: 'ЖУРНАЛ',
229 items:[ 260 items:[
230 { 261 {
......
...@@ -79,12 +79,9 @@ Ext.define('App.controller.DeviceControl', { ...@@ -79,12 +79,9 @@ Ext.define('App.controller.DeviceControl', {
79 // Ext.getCmp('ntpServer').setValue(result.ntp); 79 // Ext.getCmp('ntpServer').setValue(result.ntp);
80 80
81 }, failure: function(response, opts) { 81 }, failure: function(response, opts) {
82 Ext.Msg.alert('Ошибка', 'Сервер недоступен'); 82 Ext.Msg.alert("Ошибка", "Сервер конфигурации недоступен");
83 } 83 }
84 }); 84 });
85
86
87
88 }, 85 },
89 86
90 87
......
1 Ext.define('App.controller.Sv', {
2 extend : 'Ext.app.Controller',
3
4 init : function() {
5 this.control({
6
7 'toolbar button[action=loadSv]': {
8 click : this.loadSv
9 },
10
11 'mvvm-DnsView': {
12 selectionchange: this.gridSelectionChange,
13 viewready: this.onViewReady,
14 select: this.onRowSelect
15 },
16 'mvvm-DnsView': {
17 edit: this.onRowEdit,
18 beforeedit: this.onRowBeforeEdit
19 }
20 });
21 },
22
23 saveDns:function(btn) {
24
25
26 var grid = btn.up('gridpanel');
27 var store = grid.getStore();
28
29 var records = [];
30
31 store.each(function(r){
32 records.push({
33 id: r.get("id"),
34 ip: r.get("ip")
35 });
36 });
37
38
39 var data=Ext.util.JSON.encode(records);
40
41 Ext.Ajax.request({
42 method: "POST",
43 url: 'api/dns/update',
44 headers: {
45 'Accept': 'application/json',
46 'Content-Type': 'application/json'
47 },
48 params: data,
49 success: function(response, opts) {
50
51 var Ok = Ext.JSON.decode(response.responseText);
52 if (Ok) {
53 Ext.Msg.alert('Success', 'Сохранение выполнено успешно');
54 }else {
55 Ext.Msg.alert('Failure', 'Ошибка сохранения');
56 }
57
58 }, failure: function(response, opts) {
59
60 Ext.Msg.alert('Failure', 'Ошибка сохранения');
61 }
62 });
63
64
65
66
67
68
69
70
71
72
73
74
75
76 //fires create, update and delete request when calling sync and commit changes in the store when autoSync=false
77 /*
78 store.sync({
79 success : function(batch, eOpts){
80 Ext.Msg.alert('Status', 'Changes saved successfully.');
81 },
82 failure : function(record, eOpts){
83 Ext.Msg.alert('Status', 'Request failed.');
84 }
85 });
86 */
87
88 },
89
90 loadSv:function(btn) {
91
92 var grid = btn.up('gridpanel');
93 var store = grid.getStore();
94 store.load();
95
96 },
97
98 onRowEdit:function(editor, context, eOpts) {
99
100 },
101
102 onRowBeforeEdit:function() {
103
104
105 },
106
107
108
109 newDns : function(btn) {
110
111
112 var grid = btn.up('gridpanel');
113 var store = grid.getStore();
114 var rowEditing=grid.getPlugin('modelDnsEditPlagin');
115
116
117 rowEditing.cancelEdit();
118
119 var records = grid.getStore().getRange();
120
121 var r = Ext.create('App.model.Dns', {
122 id: records.length,
123 ip: '8.8.8.8',
124 });
125 store.insert(0, r);
126
127
128 var records = [];
129
130 store.each(function(r){
131 records.push({
132 id: r.get("id"),
133 ip: r.get("ip")
134 });
135 });
136
137 rowEditing.startEdit(0, 0);
138
139 },
140
141 delDns:function(btn) {
142
143
144 var grid = btn.up('gridpanel');
145 var store=grid.getStore();
146
147
148 var selectedRows = grid.getSelectionModel().getSelection();
149
150 if(selectedRows.length) {
151
152 store.remove(selectedRows);
153 } else {
154 Ext.Msg.alert('Статус', 'Выберите запись');
155 }
156 },
157
158 gridSelectionChange:function(selModel, selections, eOpts) {
159
160 /*
161 var grid = selModel.view.ownerCt;
162 var btnDelete=grid.down('button[itemId=deleteDnsButton]');
163
164 btnDelete.setDisabled(false);
165
166 console.log(selections[0].data);
167 var json=Ext.util.JSON.encode(selections[0].data);
168 console.log(json);
169 */
170 },
171 onViewReady:function() {
172 },
173
174 onRowSelect: function(selModel, record, index, opts) {
175
176
177 }
178
179 });
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
1 Ext.define('App.model.Sv', {
2 extend : 'Ext.data.Model',
3
4 fields : [{
5 name:'id',
6 type:'int'
7 },
8 {
9 name:'process',
10 type:'string'
11 },
12 {
13 name:'autostart',
14 type:'boolean'
15 },
16
17 {
18 name:'isrun',
19 type:'boolean'
20 },
21
22 {
23 name:'starttime',
24 type:'int'
25 },
26 {
27 name:'stoptime',
28 type:'int'
29 } ]
30 });
31
1
2 Ext.define('App.store.Sv', {
3 extend : 'Ext.data.Store',
4
5 requires : [
6 'App.model.Sv'
7 ],
8
9 storeId : 'Sv',
10 model : 'App.model.Sv',
11
12 autoLoad: true,
13 autoSync: true,
14 alias: 'store.devices',
15 proxy : {
16 type : 'ajax',
17 api: {
18 read: 'api/sv/all',
19 create : 'null',
20 update : 'null',
21 destroy : 'null'
22 },
23 actionMethods :
24 {
25 destroy : 'POST',
26 read : 'GET',
27 create : 'POST',
28 update : 'POST'
29 },
30 reader : {
31 type : 'json',
32 idProperty : 'id'
33 },
34 }
35 });
...\ No newline at end of file ...\ No newline at end of file
1
2
3 function renderercell(value, metaData, record, row, col, store, gridView) {
4 return '<div style="font-size: 14px; color:#3892d3; text-align:center;">'+value+'</div>';
5 }
6
7
8 function rendererstatusimg(value, metaData, record, rowIndex, colIndex, store) {
9 if(value) {
10 // return '<div style="font-size: 14px; color:#3892d3; text-align:center;">'+'Запущен'+'</div>';
11 return '<span><img src="resources/img/button-green.png" height="18" width="18"/> </span>';
12 }else {
13 return '<div style="font-size: 14px; color:#3892d3; text-align:center;">'+'Остановлен'+'</div>';
14 }
15 }
16
17 function rendererstatustitle(value, metaData, record, rowIndex, colIndex, store) {
18 if(value) {
19 return '<div style="font-size: 14px; color:#3892d3; text-align:center;">'+'Запущен'+'</div>';
20
21 }else {
22 return '<div style="font-size: 14px; color:#3892d3; text-align:center;">'+'Остановлен'+'</div>';
23 }
24 }
25
26
27
28 Ext.define('App.view.Sv', {
29 extend : 'Ext.grid.Panel',
30 xtype : 'mvvm-SvView',
31 title : 'Управление службами',
32 store : 'Sv',
33
34 bbar: {
35 items: [
36 {
37 xtype: 'button',
38 iconCls:'load',
39 itemId: 'LoadSvButton',
40 text: 'Обновить',
41 action: 'loadSv',
42 disabled:false
43 }
44 ]
45 },
46 width: 500,
47 height: 300,
48 selType: 'rowmodel',
49 plugins: [new Ext.create('Ext.grid.plugin.RowEditing', {
50 clicksToEdit: 2,
51 pluginId: 'modelSvEditPlagin'
52 })
53 ],
54 columns: [{
55 text : '№',
56 dataIndex : 'id',
57 flex: 1,
58 hidden:true
59 },
60
61
62 {
63 text : 'Статус',
64 dataIndex : 'isrun',
65 flex : 1,
66 renderer:rendererstatusimg,
67 // editor: new Ext.form.TextField({
68 allowBlank: true
69 // })
70 },
71
72
73 {
74 text : 'Процесс',
75 dataIndex : 'process',
76 flex : 1,
77 renderer:renderercell,
78 // editor: new Ext.form.TextField({
79 // allowBlank: true
80 // })
81 },
82
83 {
84 text : 'Примечание',
85 dataIndex : 'isrun',
86 flex : 1,
87 renderer:rendererstatustitle,
88 // editor: new Ext.form.TextField({
89 allowBlank: true
90 // })
91 },
92
93 {
94 text : 'Автозагрузка',
95 dataIndex : 'autostart',
96 flex : 1,
97 xtype: 'checkcolumn'
98 },
99
100
101 {
102 xtype:'actioncolumn',
103 margin: "10 20 20 20",
104 items: [{
105 icon: 'resources/img/start.png',
106 tooltip: 'Запустить',
107 margin: "10 20 20 20",
108 handler: function(grid, rowIndex, colIndex) {
109 var rec = grid.getStore().getAt(rowIndex);
110 alert("Edit " + rec.get('firstname'));
111 }
112 },{
113 icon: 'resources/img/stop.png',
114 tooltip: 'Остановить',
115 margin: "10 20 20 20",
116 handler: function(grid, rowIndex, colIndex) {
117 var rec = grid.getStore().getAt(rowIndex);
118 alert("Terminate " + rec.get('firstname'));
119 }
120 },
121 {
122 icon: 'resources/img/replay.png',
123 tooltip: 'Перезапустить',
124 margin: "10 20 20 20",
125 handler: function(grid, rowIndex, colIndex) {
126 var rec = grid.getStore().getAt(rowIndex);
127 alert("Terminate " + rec.get('firstname'));
128 }
129 }
130
131 ]
132 }
133
134
135
136 ]
137 });
138
139
140
141
142
143
144
145
146
147
148
149
150
1 package org.emercit.pckutils.cmd;
2
3 import java.util.Vector;
4
5 import org.apache.log4j.Logger;
6 import org.emercit.dtmanager.service.NtpLinux;
7
8 public class CmdLog {
9
10 private static final Logger log = Logger.getLogger(CmdLog.class);
11
12 public void print(Vector<String> values){
13
14 for (String s:values) {
15 log.info(s);
16 }
17 }
18
19 }
1 package org.emercit.svmanager.model; 1 package org.emercit.svmanager.model;
2 2
3
4
5
6 import java.io.Serializable; 3 import java.io.Serializable;
7 import java.util.Vector; 4 import java.util.Vector;
8 5
...@@ -18,6 +15,9 @@ private static final long serialVersionUID = 1L; ...@@ -18,6 +15,9 @@ private static final long serialVersionUID = 1L;
18 15
19 private boolean isrun; 16 private boolean isrun;
20 17
18 private int starttime; // время запуска процесса в мс
19
20 private int stoptime; // время остановки процесса
21 21
22 public SvBean() { 22 public SvBean() {
23 23
...@@ -55,6 +55,22 @@ private static final long serialVersionUID = 1L; ...@@ -55,6 +55,22 @@ private static final long serialVersionUID = 1L;
55 public void setIsrun(boolean value) { 55 public void setIsrun(boolean value) {
56 this.isrun=value; 56 this.isrun=value;
57 } 57 }
58
59 public void setStarttime(int value) {
60 this.starttime=value;
61 }
62
63 public int getStarttime() {
64 return starttime;
65 }
66
67 public void setStoptime(int value) {
68 this.stoptime=value;
69 }
70
71 public int getStoptime(){
72 return this.stoptime;
73 }
58 74
59 } 75 }
60 76
......
...@@ -6,7 +6,7 @@ import org.emercit.svmanager.model.SvBean; ...@@ -6,7 +6,7 @@ import org.emercit.svmanager.model.SvBean;
6 import org.emercit.xmldbmanager.service.Db; 6 import org.emercit.xmldbmanager.service.Db;
7 import org.emercit.svmanager.service.SvControl; 7 import org.emercit.svmanager.service.SvControl;
8 import org.emercit.utilstools.config.Paths; 8 import org.emercit.utilstools.config.Paths;
9 9 import org.emercit.utilstools.config.DefSettings;
10 10
11 public class Sv { 11 public class Sv {
12 12
...@@ -26,35 +26,39 @@ public class Sv { ...@@ -26,35 +26,39 @@ public class Sv {
26 } 26 }
27 27
28 public int init() { 28 public int init() {
29 29
30 svbeans=new Vector<SvBean>(); 30 svbeans=new Vector<SvBean>();
31 31
32 // jetty 32 // jetty
33 svbean=new SvBean(); 33 svbean=new SvBean();
34 svbean.setId(0); 34 svbean.setId(DefSettings.jetty_id);
35 svbean.setProcess(Paths.JETTY); 35 svbean.setProcess(DefSettings.jetty_process);
36 svbean.setAutostart(true); 36 svbean.setAutostart(DefSettings.jetty_autostart);
37 svbean.setIsrun(true); 37 svbean.setIsrun(DefSettings.jetty_isrun);
38 svbean.setStarttime(DefSettings.jetty_starttime);
39 svbean.setStoptime(DefSettings.jetty_stoptime);
38 svbeans.add(svbean); 40 svbeans.add(svbean);
39 41
40 // ctrlpnl 42 // ctrlpnl
41 svbean=new SvBean(); 43 svbean=new SvBean();
42 svbean.setId(1); 44 svbean.setId(DefSettings.ctrlpnl_id);
43 svbean.setProcess(Paths.CTRLPNL); 45 svbean.setProcess(DefSettings.ctrlpnl_process);
44 svbean.setAutostart(true); 46 svbean.setAutostart(DefSettings.ctrlpnl_autostart);
45 svbean.setIsrun(true); 47 svbean.setIsrun(DefSettings.ctrlpnl_isrun);
48 svbean.setStarttime(DefSettings.ctrlpnl_starttime);
49 svbean.setStoptime(DefSettings.ctrlpnl_stoptime);
46 svbeans.add(svbean); 50 svbeans.add(svbean);
47 51
48 int res=set(svbeans); 52 int res=set(svbeans);
49 53
50 for (SvBean sv:svbeans ) { 54 for (SvBean sv:svbeans ) {
51 55
52 svcontrol=new SvControl(sv.getProcess()); 56 svcontrol=new SvControl(sv);
53 57
54 if (sv.getAutostart()) { 58 if (sv.getAutostart()) {
55 svcontrol.addAutoRun(); 59 res=svcontrol.addAutoRun();
56 }else { 60 }else {
57 svcontrol.delAutoRun(); 61 res=svcontrol.delAutoRun();
58 } 62 }
59 } 63 }
60 return res; 64 return res;
......
1 package org.emercit.svmanager.service; 1 package org.emercit.svmanager.service;
2 2
3 3
4 import org.apache.log4j.Logger;
5 import org.emercit.devinfo.service.DevInfo;
4 import org.emercit.pckutils.cmd.CmdExec; 6 import org.emercit.pckutils.cmd.CmdExec;
5 import org.emercit.utilstools.config.Paths; 7 import org.emercit.utilstools.config.Paths;
6 import org.emercit.utilstools.config.Msg; 8 import org.emercit.utilstools.config.Msg;
7 9 import org.emercit.svmanager.model.SvBean;
8 import org.emercit.pckutils.checkservice.STService; 10 import org.emercit.pckutils.checkservice.STService;
11 import java.util.Vector;
12 import org.emercit.pckutils.cmd.CmdLog;
9 13
10 public class SvControl implements ISvControl { 14 public class SvControl implements ISvControl {
11 15
16 private static final Logger log = Logger.getLogger(SvControl.class);
17
12 private CmdExec cmdexec=new CmdExec(); 18 private CmdExec cmdexec=new CmdExec();
19 private CmdLog cmdLog=new CmdLog();
13 20
14 private STService st=new STService(); 21 private STService st=new STService();
15 22
16 private String process; 23 private SvBean svbean;
17 24
25 private int typeCode;
18 26
19 public SvControl(String process) { 27 public SvControl(SvBean svbean) {
20 28 this.svbean=svbean;
21 this.process=process;
22 } 29 }
23 30
31 /*
32 * Остановка процесса
33 * @see org.emercit.svmanager.service.ISvControl#stop()
34 */
24 public int stop() { 35 public int stop() {
25 36 try {
26 try { 37 cmdLog.print(cmdexec.Run(Paths.dirInit_d+" "+this.svbean.getProcess()+" "+"stop"));
27 cmdexec.Run(Paths.dirInit_d+" "+process+" "+"stop"); 38
28 39 Thread.sleep(this.svbean.getStoptime());
29 40
30 }catch(Exception e) 41 if(st.IsRun(this.svbean.getProcess())) { //если еще запущен
31 { 42 log.error(Msg.ProcessStopError.getDescription());
32 return Msg.ProcessStopError.getCode(); 43 return Msg.ProcessStopError.getCode();
33 }; 44 }
45 }catch(Exception e) {
46 log.error(e.getMessage());
47 return Msg.ProcessStopError.getCode();
48 };
49 log.info(Msg.ProcessStopSucc.getDescription());
34 return Msg.ProcessStopSucc.getCode(); 50 return Msg.ProcessStopSucc.getCode();
35 } 51 }
36 52
53
54 /*
55 * Запуск процесса
56 * @see org.emercit.svmanager.service.ISvControl#start()
57 */
37 public int start() { 58 public int start() {
38 59
39 try { cmdexec.Run(Paths.dirInit_d+process+" "+"start"); }catch(Exception e) { return Msg.ProcessStartError.getCode(); }; 60 try {
61 cmdLog.print(cmdexec.Run(Paths.dirInit_d+this.svbean.getProcess()+" "+"start"));
62
63 Thread.sleep(this.svbean.getStarttime());
64
65 if(!st.IsRun(this.svbean.getProcess())) { //если еще запущен
66 log.error(Msg.ProcessStartError.getDescription());
67 return Msg.ProcessStartError.getCode();
68 }
69
70
71 }catch(Exception e) {
72 log.error(e.getMessage());
73 return Msg.ProcessStartError.getCode();
74 };
40 75
76 log.info(Msg.ProcessStartSucc.getDescription());
41 return Msg.ProcessStartSucc.getCode(); 77 return Msg.ProcessStartSucc.getCode();
42 } 78 }
43 79
80 /*
81 * Перезапуск процесса
82 * @see org.emercit.svmanager.service.ISvControl#restart()
83 */
44 public int restart() { 84 public int restart() {
85 try {
86 cmdLog.print(cmdexec.Run(Paths.dirInit_d+this.svbean.getProcess()+" "+"restart"));
87
88 typeCode =Msg.getByCode(stop()).getTypeVariable().getCode();
89
90 if (typeCode==0) { // Нет ошибки
91
92 typeCode=Msg.getByCode(start()).getTypeVariable().getCode();
93
94 if (typeCode==0) {
95
96 log.info(Msg.ProcessRestartSucc.getDescription());
97 return Msg.ProcessRestartSucc.getCode();
98
99 }else {
100 log.error(Msg.ProcessStartError.getDescription());
101 }
102
103 }else {
104 log.error(Msg.ProcessStopError.getDescription());
105 }
106 }catch(Exception e) {
107 log.error(e.getMessage());
108 }
45 109
46 try { cmdexec.Run(Paths.dirInit_d+process+" "+"restart"); }catch(Exception e) { return Msg.ProcessRestartError.getCode(); }; 110 return Msg.ProcessRestartError.getCode();
47
48 return Msg.ProcessRestartSucc.getCode();
49 } 111 }
50 112
51 public int addAutoRun() { 113 /*
52 114 * Добавление процесса в автозагрузку
53 try { cmdexec.Run("update-rc.d "+process+" default"); }catch(Exception e) { return Msg.ProcessAddAutoRunError.getCode(); }; 115 * @see org.emercit.svmanager.service.ISvControl#addAutoRun()
54 116 */
117 public int addAutoRun() {
118 try {
119 cmdLog.print(cmdexec.Run("update-rc.d "+this.svbean.getProcess()+" default"));
120 }catch(Exception e) {
121 return Msg.ProcessAddAutoRunError.getCode();
122 };
55 return Msg.ProcessAddAutoRunSucc.getCode(); 123 return Msg.ProcessAddAutoRunSucc.getCode();
56 } 124 }
57 125
126 /*
127 * Удаление процесса из автозагрузки
128 * @see org.emercit.svmanager.service.ISvControl#delAutoRun()
129 */
58 public int delAutoRun() { 130 public int delAutoRun() {
59 131
60 try { cmdexec.Run("update-rc.d -f "+process+" remove"); }catch(Exception e) { return Msg.ProcessDelAutoRunError.getCode(); }; 132 try {
133 cmdLog.print(cmdexec.Run("update-rc.d -f "+this.svbean.getProcess()+" remove"));
134 }catch(Exception e) {
135 return Msg.ProcessDelAutoRunError.getCode();
136 };
61 137
62 return Msg.ProcessDelAutoRunSucc.getCode(); 138 return Msg.ProcessDelAutoRunSucc.getCode();
63 } 139 }
64 140
65
66
67
68 141
69 } 142 }
......
...@@ -66,6 +66,20 @@ public class DefSettings { ...@@ -66,6 +66,20 @@ public class DefSettings {
66 public static final int Server_port=80; 66 public static final int Server_port=80;
67 public static final String Server_type="СЗС"; 67 public static final String Server_type="СЗС";
68 public static final String Server_title=""; 68 public static final String Server_title="";
69 //JETTY
70 public static final int jetty_id=0;
71 public static final String jetty_process="jetty";
72 public static final boolean jetty_autostart=true;
73 public static final boolean jetty_isrun=false;
74 public static final int jetty_starttime=30000; // время запуска процесса в мс
75 public static final int jetty_stoptime=15000; // время остановки процесса
76 //CTRLPNL
77 public static final int ctrlpnl_id=1;
78 public static final String ctrlpnl_process="ctrlpnl";
79 public static final boolean ctrlpnl_autostart=true;
80 public static final boolean ctrlpnl_isrun=false;
81 public static final int ctrlpnl_starttime=10000; // время запуска процесса в мс
82 public static final int ctrlpnl_stoptime=5000; // время остановки процесса
69 83
70 84
71 85
......
...@@ -25,8 +25,8 @@ public enum Msg { ...@@ -25,8 +25,8 @@ public enum Msg {
25 ProcessStopSucc(11,TypeMsg.INFO,"Выполнена остановка процесса"), 25 ProcessStopSucc(11,TypeMsg.INFO,"Выполнена остановка процесса"),
26 ProcessStopError(12,TypeMsg.ERROR,"Ошибка при выполнении остановки процесса"), 26 ProcessStopError(12,TypeMsg.ERROR,"Ошибка при выполнении остановки процесса"),
27 27
28 ProcessStartSucc(13,TypeMsg.INFO,"Выполнена остановка процесса"), 28 ProcessStartSucc(13,TypeMsg.INFO,"Процесс успешно запущен"),
29 ProcessStartError(14,TypeMsg.ERROR,"Ошибка при выполнеии запуска процесса"), 29 ProcessStartError(14,TypeMsg.ERROR,"Ошибка запеска процесса"),
30 30
31 ProcessRestartSucc(15,TypeMsg.INFO,"Выполнена перезагрузка процесса"), 31 ProcessRestartSucc(15,TypeMsg.INFO,"Выполнена перезагрузка процесса"),
32 ProcessRestartError(16,TypeMsg.ERROR,"Ошибка при перезагрузки процесса"), 32 ProcessRestartError(16,TypeMsg.ERROR,"Ошибка при перезагрузки процесса"),
......
...@@ -3,8 +3,8 @@ package org.emercit.utilstools.config; ...@@ -3,8 +3,8 @@ package org.emercit.utilstools.config;
3 3
4 public enum TypeMsg implements TypeVariable { 4 public enum TypeMsg implements TypeVariable {
5 5
6 INFO(1,"Уведомление"), 6 INFO(0,"Уведомление"),
7 ERROR(2,"Ошибка"); 7 ERROR(1,"Ошибка");
8 8
9 private int code; 9 private int code;
10 10
......