save
Showing
38 changed files
with
322 additions
and
96 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.13</version> | 139 | <version>1.16</version> |
| 140 | </dependency> | 140 | </dependency> |
| 141 | 141 | ||
| 142 | <dependency> | 142 | <dependency> | ... | ... |
No preview for this file type
| 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.14</version> | ||
| 8 | </project> |
| 1 | 426f322090d8d66055da6a43c058ea19 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | b1b960fa6321eea32082c94d611756e69724daed | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
No preview for this file type
| 1 | e95f49d7f2e1b3caa3e566feee01459d | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | 0210e0961c022e8c0a4ec815d6181add0e5f8b61 | ||
| ... | \ 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.15</version> | ||
| 8 | </project> |
| 1 | 014e10c87b5f4a41358d605c462934ca | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | 2ed6591e4cfed4cb6229bc80fdb81e397da87486 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
No preview for this file type
| 1 | bcdfbf5a0dc0e1bed38b43aeb28cd039 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | 0575fa1873070b23de0ee548913cf290ec7d1407 | ||
| ... | \ 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.16</version> | ||
| 8 | </project> |
| 1 | 43fae5cf493994c89ff6fd6d21db8940 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | 0bd15fdcf0fe0467be5ceb0ef7d338a33694f45e | ||
| ... | \ 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.13</release> | 6 | <release>1.16</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> |
| ... | @@ -19,7 +19,10 @@ | ... | @@ -19,7 +19,10 @@ |
| 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 | <version>1.13</version> |
| 22 | <version>1.14</version> | ||
| 23 | <version>1.15</version> | ||
| 24 | <version>1.16</version> | ||
| 22 | </versions> | 25 | </versions> |
| 23 | <lastUpdated>20150730153808</lastUpdated> | 26 | <lastUpdated>20150803074609</lastUpdated> |
| 24 | </versioning> | 27 | </versioning> |
| 25 | </metadata> | 28 | </metadata> | ... | ... |
| ... | @@ -47,12 +47,14 @@ public class SvController { | ... | @@ -47,12 +47,14 @@ public class SvController { |
| 47 | return Msg.getMsgResultByCode(SvService.INSTANCE.Update(bean)); | 47 | return Msg.getMsgResultByCode(SvService.INSTANCE.Update(bean)); |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | |||
| 50 | @RequestMapping(value="sv/start" , method = RequestMethod.POST) | 51 | @RequestMapping(value="sv/start" , method = RequestMethod.POST) |
| 51 | public @ResponseBody MsgResult start(@RequestBody SvBean bean) { | 52 | public @ResponseBody MsgResult start(@RequestBody SvBean bean) { |
| 52 | 53 | ||
| 53 | return Msg.getMsgResultByCode(SvService.INSTANCE.Start(bean)); | 54 | return Msg.getMsgResultByCode(SvService.INSTANCE.Start(bean)); |
| 54 | } | 55 | } |
| 55 | 56 | ||
| 57 | |||
| 56 | @RequestMapping(value="sv/stop" , method = RequestMethod.POST) | 58 | @RequestMapping(value="sv/stop" , method = RequestMethod.POST) |
| 57 | public @ResponseBody MsgResult stop(@RequestBody SvBean bean) { | 59 | public @ResponseBody MsgResult stop(@RequestBody SvBean bean) { |
| 58 | 60 | ... | ... |
| ... | @@ -81,26 +81,19 @@ public enum SvService { | ... | @@ -81,26 +81,19 @@ public enum SvService { |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | public int Start(SvBean svbean) { | 83 | public int Start(SvBean svbean) { |
| 84 | svcontrol=new SvControl(svbean.getProcess()); | 84 | svcontrol=new SvControl(svbean); |
| 85 | return svcontrol.start(); | 85 | return svcontrol.start(); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | public int Stop(SvBean svbean) { | 88 | public int Stop(SvBean svbean) { |
| 89 | svcontrol=new SvControl(svbean.getProcess()); | 89 | svcontrol=new SvControl(svbean); |
| 90 | return svcontrol.stop(); | 90 | return svcontrol.stop(); |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | public int Restart(SvBean svbean) { | 93 | public int Restart(SvBean svbean) { |
| 94 | svcontrol=new SvControl(svbean.getProcess()); | 94 | svcontrol=new SvControl(svbean); |
| 95 | return svcontrol.restart(); | 95 | return svcontrol.restart(); |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | 98 | ||
| 99 | |||
| 100 | |||
| 101 | |||
| 102 | |||
| 103 | |||
| 104 | |||
| 105 | |||
| 106 | } | 99 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -71,17 +71,6 @@ Ext.define('App.controller.Dns', { | ... | @@ -71,17 +71,6 @@ Ext.define('App.controller.Dns', { |
| 71 | } | 71 | } |
| 72 | }); | 72 | }); |
| 73 | 73 | ||
| 74 | |||
| 75 | |||
| 76 | |||
| 77 | |||
| 78 | |||
| 79 | |||
| 80 | |||
| 81 | |||
| 82 | |||
| 83 | |||
| 84 | |||
| 85 | 74 | ||
| 86 | //fires create, update and delete request when calling sync and commit changes in the store when autoSync=false | 75 | //fires create, update and delete request when calling sync and commit changes in the store when autoSync=false |
| 87 | /* | 76 | /* | ... | ... |
| ... | @@ -21,7 +21,6 @@ Ext.define('App.controller.Sv', { | ... | @@ -21,7 +21,6 @@ Ext.define('App.controller.Sv', { |
| 21 | }, | 21 | }, |
| 22 | 22 | ||
| 23 | saveDns:function(btn) { | 23 | saveDns:function(btn) { |
| 24 | |||
| 25 | 24 | ||
| 26 | var grid = btn.up('gridpanel'); | 25 | var grid = btn.up('gridpanel'); |
| 27 | var store = grid.getStore(); | 26 | var store = grid.getStore(); |
| ... | @@ -36,7 +35,7 @@ Ext.define('App.controller.Sv', { | ... | @@ -36,7 +35,7 @@ Ext.define('App.controller.Sv', { |
| 36 | }); | 35 | }); |
| 37 | 36 | ||
| 38 | 37 | ||
| 39 | var data=Ext.util.JSON.encode(records); | 38 | var data=Ext.util.JSON.encode(records); |
| 40 | 39 | ||
| 41 | Ext.Ajax.request({ | 40 | Ext.Ajax.request({ |
| 42 | method: "POST", | 41 | method: "POST", | ... | ... |
| ... | @@ -23,14 +23,11 @@ function rendererstatustitle(value, metaData, record, rowIndex, colIndex, store) | ... | @@ -23,14 +23,11 @@ function rendererstatustitle(value, metaData, record, rowIndex, colIndex, store) |
| 23 | } | 23 | } |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | |||
| 27 | |||
| 28 | Ext.define('App.view.Sv', { | 26 | Ext.define('App.view.Sv', { |
| 29 | extend : 'Ext.grid.Panel', | 27 | extend : 'Ext.grid.Panel', |
| 30 | xtype : 'mvvm-SvView', | 28 | xtype : 'mvvm-SvView', |
| 31 | title : 'Управление службами', | 29 | title : 'Управление службами', |
| 32 | store : 'Sv', | 30 | store : 'Sv', |
| 33 | |||
| 34 | bbar: { | 31 | bbar: { |
| 35 | items: [ | 32 | items: [ |
| 36 | { | 33 | { |
| ... | @@ -96,7 +93,6 @@ Ext.define('App.view.Sv', { | ... | @@ -96,7 +93,6 @@ Ext.define('App.view.Sv', { |
| 96 | xtype: 'checkcolumn' | 93 | xtype: 'checkcolumn' |
| 97 | }, | 94 | }, |
| 98 | 95 | ||
| 99 | |||
| 100 | { | 96 | { |
| 101 | xtype:'actioncolumn', | 97 | xtype:'actioncolumn', |
| 102 | width:170, | 98 | width:170, |
| ... | @@ -104,15 +100,45 @@ Ext.define('App.view.Sv', { | ... | @@ -104,15 +100,45 @@ Ext.define('App.view.Sv', { |
| 104 | icon: 'resources/img/start.png', | 100 | icon: 'resources/img/start.png', |
| 105 | tooltip: 'Запустить', | 101 | tooltip: 'Запустить', |
| 106 | handler: function(grid, rowIndex, colIndex) { | 102 | handler: function(grid, rowIndex, colIndex) { |
| 107 | var rec = grid.getStore().getAt(rowIndex); | 103 | var rec = grid.getStore().getAt(rowIndex); |
| 108 | alert("Edit " + rec.get('firstname')); | 104 | var data=Ext.util.JSON.encode(rec.data); |
| 105 | |||
| 106 | grid.mask("Запуск..."); | ||
| 107 | |||
| 108 | Ext.Ajax.request({ | ||
| 109 | method: "POST", | ||
| 110 | url: 'api/sv/start', | ||
| 111 | timeout: 60000, | ||
| 112 | headers: { | ||
| 113 | 'Accept': 'application/json', | ||
| 114 | 'Content-Type': 'application/json' | ||
| 115 | }, | ||
| 116 | params:data, | ||
| 117 | success: function(response, opts) { | ||
| 118 | |||
| 119 | grid.unmask(); | ||
| 120 | |||
| 121 | var result = Ext.JSON.decode(response.responseText); | ||
| 122 | |||
| 123 | |||
| 124 | Ext.Msg.alert(result.type+" "+"Код-"+result.code,result.message); | ||
| 125 | |||
| 126 | }, failure: function(response, opts) { | ||
| 127 | grid.unmask(); | ||
| 128 | Ext.Msg.alert('Failure', 'Ошибка соединения'); | ||
| 129 | } | ||
| 130 | }); | ||
| 131 | |||
| 109 | } | 132 | } |
| 110 | },{ | 133 | },{ |
| 111 | icon: 'resources/img/stop.png', | 134 | icon: 'resources/img/stop.png', |
| 112 | tooltip: 'Остановить', | 135 | tooltip: 'Остановить', |
| 113 | handler: function(grid, rowIndex, colIndex) { | 136 | handler: function(grid, rowIndex, colIndex) { |
| 114 | var rec = grid.getStore().getAt(rowIndex); | 137 | var rec = grid.getStore().getAt(rowIndex); |
| 115 | alert("Terminate " + rec.get('firstname')); | 138 | |
| 139 | console.log(rec); | ||
| 140 | |||
| 141 | //alert("Terminate " + rec.get('firstname')); | ||
| 116 | } | 142 | } |
| 117 | }, | 143 | }, |
| 118 | { | 144 | { |
| ... | @@ -120,7 +146,8 @@ Ext.define('App.view.Sv', { | ... | @@ -120,7 +146,8 @@ Ext.define('App.view.Sv', { |
| 120 | tooltip: 'Перезапустить', | 146 | tooltip: 'Перезапустить', |
| 121 | handler: function(grid, rowIndex, colIndex) { | 147 | handler: function(grid, rowIndex, colIndex) { |
| 122 | var rec = grid.getStore().getAt(rowIndex); | 148 | var rec = grid.getStore().getAt(rowIndex); |
| 123 | alert("Terminate " + rec.get('firstname')); | 149 | |
| 150 | console.log(rec); | ||
| 124 | } | 151 | } |
| 125 | } | 152 | } |
| 126 | 153 | ... | ... |
| ... | @@ -32,13 +32,12 @@ | ... | @@ -32,13 +32,12 @@ |
| 32 | </build> | 32 | </build> |
| 33 | 33 | ||
| 34 | <dependencies> | 34 | <dependencies> |
| 35 | <dependency> | 35 | <dependency> |
| 36 | <groupId>junit</groupId> | 36 | <groupId>junit</groupId> |
| 37 | <artifactId>junit</artifactId> | 37 | <artifactId>junit</artifactId> |
| 38 | <version>3.8.1</version> | 38 | <version>4.10</version> |
| 39 | <scope>test</scope> | 39 | </dependency> |
| 40 | </dependency> | 40 | |
| 41 | |||
| 42 | 41 | ||
| 43 | <dependency> | 42 | <dependency> |
| 44 | <groupId>com.jcraft</groupId> | 43 | <groupId>com.jcraft</groupId> | ... | ... |
| ... | @@ -35,6 +35,12 @@ import org.emercit.pckutils.checkservice.STService; | ... | @@ -35,6 +35,12 @@ import org.emercit.pckutils.checkservice.STService; |
| 35 | 35 | ||
| 36 | import org.emercit.utilstools.service.Settings; | 36 | import org.emercit.utilstools.service.Settings; |
| 37 | 37 | ||
| 38 | import org.emercit.svmanager.service.SvControl; | ||
| 39 | |||
| 40 | import org.emercit.svmanager.service.Sv; | ||
| 41 | |||
| 42 | import org.emercit.svmanager.model.SvBean; | ||
| 43 | |||
| 38 | public class DevToolsBean extends RoundPanel implements Externalizable { | 44 | public class DevToolsBean extends RoundPanel implements Externalizable { |
| 39 | 45 | ||
| 40 | private static final Logger log = Logger.getLogger(DevToolsBean.class); | 46 | private static final Logger log = Logger.getLogger(DevToolsBean.class); |
| ... | @@ -62,7 +68,16 @@ public class DevToolsBean extends RoundPanel implements Externalizable { | ... | @@ -62,7 +68,16 @@ public class DevToolsBean extends RoundPanel implements Externalizable { |
| 62 | public Update update=null; | 68 | public Update update=null; |
| 63 | 69 | ||
| 64 | public boolean block=false; | 70 | public boolean block=false; |
| 71 | |||
| 72 | public SvBean svbean; | ||
| 73 | |||
| 74 | public SvControl svcontrol; | ||
| 75 | |||
| 76 | public Sv sv; | ||
| 77 | |||
| 78 | |||
| 65 | 79 | ||
| 80 | |||
| 66 | protected EventListenerList listenerList = new EventListenerList(); | 81 | protected EventListenerList listenerList = new EventListenerList(); |
| 67 | 82 | ||
| 68 | 83 | ||
| ... | @@ -119,6 +134,15 @@ public class DevToolsBean extends RoundPanel implements Externalizable { | ... | @@ -119,6 +134,15 @@ public class DevToolsBean extends RoundPanel implements Externalizable { |
| 119 | lblStatus.setFont(font); | 134 | lblStatus.setFont(font); |
| 120 | add(lblStatus); | 135 | add(lblStatus); |
| 121 | 136 | ||
| 137 | sv=new Sv(); | ||
| 138 | |||
| 139 | for (SvBean bean:sv.get()) { | ||
| 140 | |||
| 141 | if (bean.getProcess().equals("jetty")) { | ||
| 142 | |||
| 143 | svcontrol=new SvControl(bean); | ||
| 144 | } | ||
| 145 | } | ||
| 122 | 146 | ||
| 123 | timerAnimate.schedule(new Task(),0,10000); | 147 | timerAnimate.schedule(new Task(),0,10000); |
| 124 | } | 148 | } |
| ... | @@ -136,8 +160,7 @@ public class DevToolsBean extends RoundPanel implements Externalizable { | ... | @@ -136,8 +160,7 @@ public class DevToolsBean extends RoundPanel implements Externalizable { |
| 136 | 160 | ||
| 137 | lblStatus.setIcon(new ImageIcon(DevToolsBean.class.getResource("/up.png"))); | 161 | lblStatus.setIcon(new ImageIcon(DevToolsBean.class.getResource("/up.png"))); |
| 138 | lblStatus.setForeground(Color.GREEN); | 162 | lblStatus.setForeground(Color.GREEN); |
| 139 | lblStatus.setText("- Web конфигуратор запущен."); | 163 | lblStatus.setText("- Web конфигуратор запущен"); |
| 140 | |||
| 141 | 164 | ||
| 142 | }else { | 165 | }else { |
| 143 | 166 | ||
| ... | @@ -146,9 +169,7 @@ public class DevToolsBean extends RoundPanel implements Externalizable { | ... | @@ -146,9 +169,7 @@ public class DevToolsBean extends RoundPanel implements Externalizable { |
| 146 | 169 | ||
| 147 | lblStatus.setIcon(new ImageIcon(DevToolsBean.class.getResource("/down.png"))); | 170 | lblStatus.setIcon(new ImageIcon(DevToolsBean.class.getResource("/down.png"))); |
| 148 | lblStatus.setForeground(Color.WHITE); | 171 | lblStatus.setForeground(Color.WHITE); |
| 149 | lblStatus.setText("- Web конфигуратор не запущен."); | 172 | lblStatus.setText("- Web конфигуратор не запущен"); |
| 150 | |||
| 151 | |||
| 152 | } | 173 | } |
| 153 | }catch(Exception e){ | 174 | }catch(Exception e){ |
| 154 | log.error(e.getMessage()); | 175 | log.error(e.getMessage()); |
| ... | @@ -161,35 +182,60 @@ public class DevToolsBean extends RoundPanel implements Externalizable { | ... | @@ -161,35 +182,60 @@ public class DevToolsBean extends RoundPanel implements Externalizable { |
| 161 | { | 182 | { |
| 162 | public void actionPerformed(ActionEvent e) | 183 | public void actionPerformed(ActionEvent e) |
| 163 | { | 184 | { |
| 164 | 185 | new SwingWorker<Void, Void>() | |
| 165 | btnStart.setEnabled(false); | 186 | { |
| 166 | btnStop.setEnabled(false); | 187 | protected Void doInBackground() throws Exception |
| 167 | lblStatus.setForeground(Color.YELLOW); | 188 | { |
| 168 | lblStatus.setText(" - выполняется запуск Web конфигуратора ..."); | 189 | |
| 169 | 190 | btnStart.setEnabled(false); | |
| 170 | block=true; | 191 | btnStop.setEnabled(false); |
| 171 | 192 | lblStatus.setForeground(Color.YELLOW); | |
| 172 | //TODO | 193 | lblStatus.setText(" - выполняется запуск Web конфигуратора ..."); |
| 173 | 194 | ||
| 174 | block=false; | 195 | block=true; |
| 175 | } | 196 | |
| 176 | } | 197 | svcontrol.start(); |
| 177 | 198 | ||
| 199 | block=false; | ||
| 200 | |||
| 201 | return null; | ||
| 202 | |||
| 203 | } | ||
| 204 | |||
| 205 | }.execute(); | ||
| 206 | |||
| 207 | } | ||
| 208 | } | ||
| 209 | |||
| 178 | 210 | ||
| 179 | public class Stop implements ActionListener | 211 | public class Stop implements ActionListener |
| 180 | { | 212 | { |
| 181 | public void actionPerformed(ActionEvent e) | 213 | public void actionPerformed(ActionEvent e) |
| 182 | { | 214 | { |
| 183 | btnStart.setEnabled(false); | 215 | |
| 184 | btnStop.setEnabled(false); | 216 | new SwingWorker<Void, Void>() |
| 185 | lblStatus.setForeground(Color.YELLOW); | 217 | { |
| 186 | lblStatus.setText(" - выполняется остановка Web конфигуратора ..."); | 218 | protected Void doInBackground() throws Exception |
| 187 | 219 | { | |
| 188 | block=true; | 220 | |
| 189 | 221 | btnStart.setEnabled(false); | |
| 190 | //TODO | 222 | btnStop.setEnabled(false); |
| 191 | 223 | lblStatus.setForeground(Color.YELLOW); | |
| 192 | block=false; | 224 | lblStatus.setText(" - выполняется остановка Web конфигуратора ..."); |
| 225 | |||
| 226 | block=true; | ||
| 227 | |||
| 228 | svcontrol.start(); | ||
| 229 | |||
| 230 | block=false; | ||
| 231 | |||
| 232 | return null; | ||
| 233 | } | ||
| 234 | |||
| 235 | }.execute(); | ||
| 236 | |||
| 237 | |||
| 238 | |||
| 193 | 239 | ||
| 194 | 240 | ||
| 195 | } | 241 | } | ... | ... |
| ... | @@ -12,8 +12,27 @@ public class STService { | ... | @@ -12,8 +12,27 @@ public class STService { |
| 12 | 12 | ||
| 13 | public boolean IsRun(String service) throws Exception { | 13 | public boolean IsRun(String service) throws Exception { |
| 14 | 14 | ||
| 15 | Vector<String> values=cmd.Run(Paths.FINDPROCESS_SCRIPT+" "+service); | 15 | |
| 16 | return Boolean.valueOf(values.firstElement()); | 16 | Vector<String> values=new Vector<String>(); |
| 17 | |||
| 18 | |||
| 19 | switch (service) { | ||
| 20 | |||
| 21 | case "jetty": | ||
| 22 | values=cmd.Run("ps aux | grep start.jar | grep -v grep | wc -l"); | ||
| 23 | break; | ||
| 24 | case "ctrlpnl": | ||
| 25 | values=cmd.Run("ps aux | grep CtrlPnl.jar | grep -v grep | wc -l"); | ||
| 26 | default: | ||
| 27 | |||
| 28 | break; | ||
| 29 | } | ||
| 30 | int value=Integer.valueOf(values.firstElement()); | ||
| 31 | if (value==1) { | ||
| 32 | return true; | ||
| 33 | } | ||
| 34 | |||
| 35 | return false; | ||
| 17 | } | 36 | } |
| 18 | 37 | ||
| 19 | } | 38 | } | ... | ... |
| ... | @@ -28,7 +28,6 @@ public class Sv { | ... | @@ -28,7 +28,6 @@ public class Sv { |
| 28 | public int init() { | 28 | public int init() { |
| 29 | 29 | ||
| 30 | svbeans=new Vector<SvBean>(); | 30 | svbeans=new Vector<SvBean>(); |
| 31 | |||
| 32 | // jetty | 31 | // jetty |
| 33 | svbean=new SvBean(); | 32 | svbean=new SvBean(); |
| 34 | svbean.setId(DefSettings.jetty_id); | 33 | svbean.setId(DefSettings.jetty_id); | ... | ... |
| ... | @@ -58,6 +58,9 @@ public class SvControl implements ISvControl { | ... | @@ -58,6 +58,9 @@ public class SvControl implements ISvControl { |
| 58 | public int start() { | 58 | public int start() { |
| 59 | 59 | ||
| 60 | try { | 60 | try { |
| 61 | |||
| 62 | System.out.println(Paths.dirInit_d+this.svbean.getProcess()+" "+"start"); | ||
| 63 | |||
| 61 | cmdLog.print(cmdexec.Run(Paths.dirInit_d+this.svbean.getProcess()+" "+"start")); | 64 | cmdLog.print(cmdexec.Run(Paths.dirInit_d+this.svbean.getProcess()+" "+"start")); |
| 62 | 65 | ||
| 63 | Thread.sleep(this.svbean.getStarttime()); | 66 | Thread.sleep(this.svbean.getStarttime()); | ... | ... |
| ... | @@ -13,23 +13,6 @@ public class App | ... | @@ -13,23 +13,6 @@ public class App |
| 13 | 13 | ||
| 14 | public static void main( String[] args ) | 14 | public static void main( String[] args ) |
| 15 | { | 15 | { |
| 16 | 16 | System.out.println("");; | |
| 17 | |||
| 18 | |||
| 19 | |||
| 20 | |||
| 21 | System.out.println( "UtilsTools!" ); | ||
| 22 | |||
| 23 | Sv sv=new Sv(); | ||
| 24 | |||
| 25 | // Процесс инит | ||
| 26 | |||
| 27 | sv.init(); | ||
| 28 | |||
| 29 | |||
| 30 | |||
| 31 | |||
| 32 | |||
| 33 | |||
| 34 | } | 17 | } |
| 35 | } | 18 | } | ... | ... |
| ... | @@ -26,7 +26,7 @@ public enum Msg { | ... | @@ -26,7 +26,7 @@ public enum Msg { |
| 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,"Ошибка при перезагрузки процесса"), | ... | ... |
| ... | @@ -4,7 +4,7 @@ public class Paths { | ... | @@ -4,7 +4,7 @@ public class Paths { |
| 4 | 4 | ||
| 5 | public static final String dirBeans="/opt/apps/beans/"; | 5 | public static final String dirBeans="/opt/apps/beans/"; |
| 6 | public static final String dirScripts="/opt/apps/scripts/"; | 6 | public static final String dirScripts="/opt/apps/scripts/"; |
| 7 | public static final String dirInit_d="/etc/init.d"; | 7 | public static final String dirInit_d="/etc/init.d/"; |
| 8 | 8 | ||
| 9 | //BEANS | 9 | //BEANS |
| 10 | public static final String BEAN_GSM=dirBeans+"GSMBean.xml"; | 10 | public static final String BEAN_GSM=dirBeans+"GSMBean.xml"; |
| ... | @@ -20,7 +20,7 @@ public class Paths { | ... | @@ -20,7 +20,7 @@ public class Paths { |
| 20 | public static final String FINDPROCESS_SCRIPT=dirScripts+"findprocess.sh"; | 20 | public static final String FINDPROCESS_SCRIPT=dirScripts+"findprocess.sh"; |
| 21 | 21 | ||
| 22 | //PROCESS | 22 | //PROCESS |
| 23 | public static final String JETTY="jetty"; | 23 | public static final String JETTY="strt"; |
| 24 | public static final String CTRLPNL="ctrlpnl"; | 24 | public static final String CTRLPNL="ctrlpnl"; |
| 25 | 25 | ||
| 26 | public static final String UTILSTOOLS_LOGFILE="/var/log/devtools.log"; | 26 | public static final String UTILSTOOLS_LOGFILE="/var/log/devtools.log"; | ... | ... |
| 1 | package org.emercit.utilstools; | ||
| 2 | |||
| 3 | |||
| 4 | import junit.framework.Test; | ||
| 5 | import junit.framework.TestCase; | ||
| 6 | import junit.framework.TestSuite; | ||
| 7 | import static org.junit.Assert.*; | ||
| 8 | |||
| 9 | import org.junit.After; | ||
| 10 | import org.junit.AfterClass; | ||
| 11 | import org.junit.Before; | ||
| 12 | import org.junit.BeforeClass; | ||
| 13 | import org.junit.Ignore; | ||
| 14 | import org.emercit.pckutils.checkservice.STService; | ||
| 15 | |||
| 16 | public class TestCheckProccess extends TestCase { | ||
| 17 | |||
| 18 | private STService stservice=new STService(); | ||
| 19 | |||
| 20 | @Ignore | ||
| 21 | @Before | ||
| 22 | public void testCheck() { | ||
| 23 | try { | ||
| 24 | // assertTrue(stservice.IsRun("jetty")); | ||
| 25 | } | ||
| 26 | catch(Exception e) { | ||
| 27 | // fail("Тест завален"); | ||
| 28 | } | ||
| 29 | |||
| 30 | assertTrue( true ); | ||
| 31 | |||
| 32 | //assertFalse(!stservice.IsRun("start.jar")); // Если true - то тест завален | ||
| 33 | // assertEquals(stservice.IsRun("start.jar")); // Если не равны - тест завален | ||
| 34 | // assertNotNull(stservice.IsRun("start.jar"))); // Если null - тест завален | ||
| 35 | //assertNull(stservice.IsRun("start.jar"))); // Если не null - тест завален | ||
| 36 | //assertNotSame(stservice.IsRun("start.jar")); // Если оба объекта являются одинаковыми(не одно и то же, что равны) - тест завален | ||
| 37 | //assertSame(stservice.IsRun("start.jar")); // Если оба объекта не являются одинаковыми - тест завален | ||
| 38 | } | ||
| 39 | |||
| 40 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | |||
| 2 | package org.emercit.utilstools; | ||
| 3 | |||
| 4 | |||
| 5 | import junit.framework.Test; | ||
| 6 | import junit.framework.TestCase; | ||
| 7 | import junit.framework.TestSuite; | ||
| 8 | import static org.junit.Assert.*; | ||
| 9 | |||
| 10 | import org.junit.After; | ||
| 11 | import org.junit.AfterClass; | ||
| 12 | import org.junit.Before; | ||
| 13 | import org.junit.BeforeClass; | ||
| 14 | import org.emercit.svmanager.service.SvControl; | ||
| 15 | import org.emercit.svmanager.service.Sv; | ||
| 16 | import org.emercit.svmanager.model.SvBean; | ||
| 17 | |||
| 18 | import java.util.Vector; | ||
| 19 | |||
| 20 | import org.emercit.utilstools.config.Msg; | ||
| 21 | |||
| 22 | public class TestSvControl extends TestCase { | ||
| 23 | |||
| 24 | private Sv sv; | ||
| 25 | |||
| 26 | private SvControl svcontrol; | ||
| 27 | |||
| 28 | private Vector<SvBean> svbeans; | ||
| 29 | |||
| 30 | |||
| 31 | |||
| 32 | |||
| 33 | public TestSvControl( String testName ) | ||
| 34 | { | ||
| 35 | super( testName ); | ||
| 36 | } | ||
| 37 | |||
| 38 | |||
| 39 | public static Test suite() | ||
| 40 | { | ||
| 41 | return new TestSuite( TestSvControl.class ); | ||
| 42 | } | ||
| 43 | |||
| 44 | /* | ||
| 45 | * Тестирование управления процессами | ||
| 46 | */ | ||
| 47 | public void testSvControl() | ||
| 48 | { | ||
| 49 | |||
| 50 | sv=new Sv(); | ||
| 51 | svbeans=sv.get(); | ||
| 52 | |||
| 53 | assertNotNull(svbeans); | ||
| 54 | |||
| 55 | for (SvBean svbean:svbeans) { | ||
| 56 | svcontrol=new SvControl(svbean); | ||
| 57 | //START | ||
| 58 | Msg msg=Msg.getByCode(svcontrol.start()); | ||
| 59 | |||
| 60 | if(msg.getTypeVariable().getCode()==1) { | ||
| 61 | fail("Тест завален"); | ||
| 62 | } | ||
| 63 | //RESTART | ||
| 64 | msg=Msg.getByCode(svcontrol.restart()); | ||
| 65 | if(msg.getTypeVariable().getCode()==1) { | ||
| 66 | fail("Тест завален"); | ||
| 67 | } | ||
| 68 | //STOP | ||
| 69 | msg=Msg.getByCode(svcontrol.stop()); | ||
| 70 | if(msg.getTypeVariable().getCode()==1) { | ||
| 71 | fail("Тест завален"); | ||
| 72 | } | ||
| 73 | } | ||
| 74 | assertTrue( true ); | ||
| 75 | } | ||
| 76 | |||
| 77 | |||
| 78 | |||
| 79 | |||
| 80 | |||
| 81 | |||
| 82 | |||
| 83 | |||
| 84 | |||
| 85 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or sign in to post a comment