Commit c1e87c75 c1e87c75bfc8568aad0a5091d7c3130e9e1c845f by root

save

1 parent 0235aab1
Showing 38 changed files with 322 additions and 96 deletions
......@@ -136,7 +136,7 @@
<dependency>
<groupId>org.emercit</groupId>
<artifactId>utilstools</artifactId>
<version>1.13</version>
<version>1.16</version>
</dependency>
<dependency>
......
528d24e7e4a499f3ffd53b20f37c1d6e
\ No newline at end of file
04c21c2a5e86f843cd60cd939caee1a12d5f75b4
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.emercit</groupId>
<artifactId>utilstools</artifactId>
<version>1.14</version>
</project>
426f322090d8d66055da6a43c058ea19
\ No newline at end of file
b1b960fa6321eea32082c94d611756e69724daed
\ No newline at end of file
e95f49d7f2e1b3caa3e566feee01459d
\ No newline at end of file
0210e0961c022e8c0a4ec815d6181add0e5f8b61
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.emercit</groupId>
<artifactId>utilstools</artifactId>
<version>1.15</version>
</project>
014e10c87b5f4a41358d605c462934ca
\ No newline at end of file
2ed6591e4cfed4cb6229bc80fdb81e397da87486
\ No newline at end of file
bcdfbf5a0dc0e1bed38b43aeb28cd039
\ No newline at end of file
0575fa1873070b23de0ee548913cf290ec7d1407
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.emercit</groupId>
<artifactId>utilstools</artifactId>
<version>1.16</version>
</project>
43fae5cf493994c89ff6fd6d21db8940
\ No newline at end of file
0bd15fdcf0fe0467be5ceb0ef7d338a33694f45e
\ No newline at end of file
......@@ -3,7 +3,7 @@
<groupId>org.emercit</groupId>
<artifactId>utilstools</artifactId>
<versioning>
<release>1.13</release>
<release>1.16</release>
<versions>
<version>1.0</version>
<version>1.1</version>
......@@ -19,7 +19,10 @@
<version>1.11</version>
<version>1.12</version>
<version>1.13</version>
<version>1.14</version>
<version>1.15</version>
<version>1.16</version>
</versions>
<lastUpdated>20150730153808</lastUpdated>
<lastUpdated>20150803074609</lastUpdated>
</versioning>
</metadata>
......
f720592af8e70c58b6c262c92ae2c999
\ No newline at end of file
9fa98839bb65299a3438bf0ffc3b165b
\ No newline at end of file
......
41e1fbb03c75906bcff785a016afcbc4b0cb5661
\ No newline at end of file
3c3be89a42621a3776013729d2f02ed02873b834
\ No newline at end of file
......
......@@ -47,12 +47,14 @@ public class SvController {
return Msg.getMsgResultByCode(SvService.INSTANCE.Update(bean));
}
@RequestMapping(value="sv/start" , method = RequestMethod.POST)
public @ResponseBody MsgResult start(@RequestBody SvBean bean) {
return Msg.getMsgResultByCode(SvService.INSTANCE.Start(bean));
}
@RequestMapping(value="sv/stop" , method = RequestMethod.POST)
public @ResponseBody MsgResult stop(@RequestBody SvBean bean) {
......
......@@ -81,26 +81,19 @@ public enum SvService {
}
public int Start(SvBean svbean) {
svcontrol=new SvControl(svbean.getProcess());
svcontrol=new SvControl(svbean);
return svcontrol.start();
}
public int Stop(SvBean svbean) {
svcontrol=new SvControl(svbean.getProcess());
svcontrol=new SvControl(svbean);
return svcontrol.stop();
}
public int Restart(SvBean svbean) {
svcontrol=new SvControl(svbean.getProcess());
svcontrol=new SvControl(svbean);
return svcontrol.restart();
}
}
\ No newline at end of file
......
......@@ -71,17 +71,6 @@ Ext.define('App.controller.Dns', {
}
});
//fires create, update and delete request when calling sync and commit changes in the store when autoSync=false
/*
......
......@@ -21,7 +21,6 @@ Ext.define('App.controller.Sv', {
},
saveDns:function(btn) {
var grid = btn.up('gridpanel');
var store = grid.getStore();
......@@ -36,7 +35,7 @@ Ext.define('App.controller.Sv', {
});
var data=Ext.util.JSON.encode(records);
var data=Ext.util.JSON.encode(records);
Ext.Ajax.request({
method: "POST",
......
......@@ -23,14 +23,11 @@ function rendererstatustitle(value, metaData, record, rowIndex, colIndex, store)
}
}
Ext.define('App.view.Sv', {
extend : 'Ext.grid.Panel',
xtype : 'mvvm-SvView',
title : 'Управление службами',
store : 'Sv',
bbar: {
items: [
{
......@@ -96,7 +93,6 @@ Ext.define('App.view.Sv', {
xtype: 'checkcolumn'
},
{
xtype:'actioncolumn',
width:170,
......@@ -104,15 +100,45 @@ Ext.define('App.view.Sv', {
icon: 'resources/img/start.png',
tooltip: 'Запустить',
handler: function(grid, rowIndex, colIndex) {
var rec = grid.getStore().getAt(rowIndex);
alert("Edit " + rec.get('firstname'));
var rec = grid.getStore().getAt(rowIndex);
var data=Ext.util.JSON.encode(rec.data);
grid.mask("Запуск...");
Ext.Ajax.request({
method: "POST",
url: 'api/sv/start',
timeout: 60000,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
params:data,
success: function(response, opts) {
grid.unmask();
var result = Ext.JSON.decode(response.responseText);
Ext.Msg.alert(result.type+" "+"Код-"+result.code,result.message);
}, failure: function(response, opts) {
grid.unmask();
Ext.Msg.alert('Failure', 'Ошибка соединения');
}
});
}
},{
icon: 'resources/img/stop.png',
tooltip: 'Остановить',
handler: function(grid, rowIndex, colIndex) {
var rec = grid.getStore().getAt(rowIndex);
alert("Terminate " + rec.get('firstname'));
console.log(rec);
//alert("Terminate " + rec.get('firstname'));
}
},
{
......@@ -120,7 +146,8 @@ Ext.define('App.view.Sv', {
tooltip: 'Перезапустить',
handler: function(grid, rowIndex, colIndex) {
var rec = grid.getStore().getAt(rowIndex);
alert("Terminate " + rec.get('firstname'));
console.log(rec);
}
}
......
......@@ -32,13 +32,12 @@
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
......
......@@ -35,6 +35,12 @@ import org.emercit.pckutils.checkservice.STService;
import org.emercit.utilstools.service.Settings;
import org.emercit.svmanager.service.SvControl;
import org.emercit.svmanager.service.Sv;
import org.emercit.svmanager.model.SvBean;
public class DevToolsBean extends RoundPanel implements Externalizable {
private static final Logger log = Logger.getLogger(DevToolsBean.class);
......@@ -62,7 +68,16 @@ public class DevToolsBean extends RoundPanel implements Externalizable {
public Update update=null;
public boolean block=false;
public SvBean svbean;
public SvControl svcontrol;
public Sv sv;
protected EventListenerList listenerList = new EventListenerList();
......@@ -119,6 +134,15 @@ public class DevToolsBean extends RoundPanel implements Externalizable {
lblStatus.setFont(font);
add(lblStatus);
sv=new Sv();
for (SvBean bean:sv.get()) {
if (bean.getProcess().equals("jetty")) {
svcontrol=new SvControl(bean);
}
}
timerAnimate.schedule(new Task(),0,10000);
}
......@@ -136,8 +160,7 @@ public class DevToolsBean extends RoundPanel implements Externalizable {
lblStatus.setIcon(new ImageIcon(DevToolsBean.class.getResource("/up.png")));
lblStatus.setForeground(Color.GREEN);
lblStatus.setText("- Web конфигуратор запущен.");
lblStatus.setText("- Web конфигуратор запущен");
}else {
......@@ -146,9 +169,7 @@ public class DevToolsBean extends RoundPanel implements Externalizable {
lblStatus.setIcon(new ImageIcon(DevToolsBean.class.getResource("/down.png")));
lblStatus.setForeground(Color.WHITE);
lblStatus.setText("- Web конфигуратор не запущен.");
lblStatus.setText("- Web конфигуратор не запущен");
}
}catch(Exception e){
log.error(e.getMessage());
......@@ -161,35 +182,60 @@ public class DevToolsBean extends RoundPanel implements Externalizable {
{
public void actionPerformed(ActionEvent e)
{
btnStart.setEnabled(false);
btnStop.setEnabled(false);
lblStatus.setForeground(Color.YELLOW);
lblStatus.setText(" - выполняется запуск Web конфигуратора ...");
block=true;
//TODO
block=false;
}
}
new SwingWorker<Void, Void>()
{
protected Void doInBackground() throws Exception
{
btnStart.setEnabled(false);
btnStop.setEnabled(false);
lblStatus.setForeground(Color.YELLOW);
lblStatus.setText(" - выполняется запуск Web конфигуратора ...");
block=true;
svcontrol.start();
block=false;
return null;
}
}.execute();
}
}
public class Stop implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
btnStart.setEnabled(false);
btnStop.setEnabled(false);
lblStatus.setForeground(Color.YELLOW);
lblStatus.setText(" - выполняется остановка Web конфигуратора ...");
block=true;
//TODO
block=false;
new SwingWorker<Void, Void>()
{
protected Void doInBackground() throws Exception
{
btnStart.setEnabled(false);
btnStop.setEnabled(false);
lblStatus.setForeground(Color.YELLOW);
lblStatus.setText(" - выполняется остановка Web конфигуратора ...");
block=true;
svcontrol.start();
block=false;
return null;
}
}.execute();
}
......
......@@ -12,8 +12,27 @@ public class STService {
public boolean IsRun(String service) throws Exception {
Vector<String> values=cmd.Run(Paths.FINDPROCESS_SCRIPT+" "+service);
return Boolean.valueOf(values.firstElement());
Vector<String> values=new Vector<String>();
switch (service) {
case "jetty":
values=cmd.Run("ps aux | grep start.jar | grep -v grep | wc -l");
break;
case "ctrlpnl":
values=cmd.Run("ps aux | grep CtrlPnl.jar | grep -v grep | wc -l");
default:
break;
}
int value=Integer.valueOf(values.firstElement());
if (value==1) {
return true;
}
return false;
}
}
......
......@@ -28,7 +28,6 @@ public class Sv {
public int init() {
svbeans=new Vector<SvBean>();
// jetty
svbean=new SvBean();
svbean.setId(DefSettings.jetty_id);
......
......@@ -58,6 +58,9 @@ public class SvControl implements ISvControl {
public int start() {
try {
System.out.println(Paths.dirInit_d+this.svbean.getProcess()+" "+"start");
cmdLog.print(cmdexec.Run(Paths.dirInit_d+this.svbean.getProcess()+" "+"start"));
Thread.sleep(this.svbean.getStarttime());
......
......@@ -13,23 +13,6 @@ public class App
public static void main( String[] args )
{
System.out.println( "UtilsTools!" );
Sv sv=new Sv();
// Процесс инит
sv.init();
System.out.println("");;
}
}
......
......@@ -26,7 +26,7 @@ public enum Msg {
ProcessStopError(12,TypeMsg.ERROR,"Ошибка при выполнении остановки процесса"),
ProcessStartSucc(13,TypeMsg.INFO,"Процесс успешно запущен"),
ProcessStartError(14,TypeMsg.ERROR,"Ошибка запеска процесса"),
ProcessStartError(14,TypeMsg.ERROR,"Ошибка запуска процесса"),
ProcessRestartSucc(15,TypeMsg.INFO,"Выполнена перезагрузка процесса"),
ProcessRestartError(16,TypeMsg.ERROR,"Ошибка при перезагрузки процесса"),
......
......@@ -4,7 +4,7 @@ public class Paths {
public static final String dirBeans="/opt/apps/beans/";
public static final String dirScripts="/opt/apps/scripts/";
public static final String dirInit_d="/etc/init.d";
public static final String dirInit_d="/etc/init.d/";
//BEANS
public static final String BEAN_GSM=dirBeans+"GSMBean.xml";
......@@ -20,7 +20,7 @@ public class Paths {
public static final String FINDPROCESS_SCRIPT=dirScripts+"findprocess.sh";
//PROCESS
public static final String JETTY="jetty";
public static final String JETTY="strt";
public static final String CTRLPNL="ctrlpnl";
public static final String UTILSTOOLS_LOGFILE="/var/log/devtools.log";
......
......@@ -29,6 +29,9 @@ public class AppTest
*/
public void testApp()
{
assertTrue( true );
}
}
......
package org.emercit.utilstools;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.emercit.pckutils.checkservice.STService;
public class TestCheckProccess extends TestCase {
private STService stservice=new STService();
@Ignore
@Before
public void testCheck() {
try {
// assertTrue(stservice.IsRun("jetty"));
}
catch(Exception e) {
// fail("Тест завален");
}
assertTrue( true );
//assertFalse(!stservice.IsRun("start.jar")); // Если true - то тест завален
// assertEquals(stservice.IsRun("start.jar")); // Если не равны - тест завален
// assertNotNull(stservice.IsRun("start.jar"))); // Если null - тест завален
//assertNull(stservice.IsRun("start.jar"))); // Если не null - тест завален
//assertNotSame(stservice.IsRun("start.jar")); // Если оба объекта являются одинаковыми(не одно и то же, что равны) - тест завален
//assertSame(stservice.IsRun("start.jar")); // Если оба объекта не являются одинаковыми - тест завален
}
}
\ No newline at end of file
package org.emercit.utilstools;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.emercit.svmanager.service.SvControl;
import org.emercit.svmanager.service.Sv;
import org.emercit.svmanager.model.SvBean;
import java.util.Vector;
import org.emercit.utilstools.config.Msg;
public class TestSvControl extends TestCase {
private Sv sv;
private SvControl svcontrol;
private Vector<SvBean> svbeans;
public TestSvControl( String testName )
{
super( testName );
}
public static Test suite()
{
return new TestSuite( TestSvControl.class );
}
/*
* Тестирование управления процессами
*/
public void testSvControl()
{
sv=new Sv();
svbeans=sv.get();
assertNotNull(svbeans);
for (SvBean svbean:svbeans) {
svcontrol=new SvControl(svbean);
//START
Msg msg=Msg.getByCode(svcontrol.start());
if(msg.getTypeVariable().getCode()==1) {
fail("Тест завален");
}
//RESTART
msg=Msg.getByCode(svcontrol.restart());
if(msg.getTypeVariable().getCode()==1) {
fail("Тест завален");
}
//STOP
msg=Msg.getByCode(svcontrol.stop());
if(msg.getTypeVariable().getCode()==1) {
fail("Тест завален");
}
}
assertTrue( true );
}
}
\ No newline at end of file