@ -1,15 +1,17 @@
const fs = require ( 'fs-extra' ) ;
module . exports = ( shepherd ) => {
module . exports = ( shepherd ) => {
shepherd . getMaxconKMDConf = ( ) => {
shepherd . getMaxconKMDConf = ( ) => {
return new shepherd . Promise ( ( resolve , reject ) => {
return new shepherd . Promise ( ( resolve , reject ) => {
shepherd . fs . readFile ( ` ${ shepherd . komodoDir } /komodo.conf ` , 'utf8' , ( err , data ) => {
fs . readFile ( ` ${ shepherd . komodoDir } /komodo.conf ` , 'utf8' , ( err , data ) => {
if ( err ) {
if ( err ) {
shepherd . log ( ` kmd conf maxconnections param read failed ` ) ;
shepherd . log ( 'kmd conf maxconnections param read failed' ) ;
resolve ( 'unset' ) ;
resolve ( 'unset' ) ;
} else {
} else {
const _ maxcon = data . match ( /maxconnections=\s*(.*)/ ) ;
const _ maxcon = data . match ( /maxconnections=\s*(.*)/ ) ;
if ( ! _ maxcon ) {
if ( ! _ maxcon ) {
shepherd . log ( ` kmd conf maxconnections param is unset ` ) ;
shepherd . log ( 'kmd conf maxconnections param is unset' ) ;
resolve ( false ) ;
resolve ( false ) ;
} else {
} else {
shepherd . log ( ` kmd conf maxconnections param is already set to ${ _ maxcon [ 1 ] } ` ) ;
shepherd . log ( ` kmd conf maxconnections param is already set to ${ _ maxcon [ 1 ] } ` ) ;
@ -22,7 +24,7 @@ module.exports = (shepherd) => {
shepherd . setMaxconKMDConf = ( limit ) => {
shepherd . setMaxconKMDConf = ( limit ) => {
return new shepherd . Promise ( ( resolve , reject ) => {
return new shepherd . Promise ( ( resolve , reject ) => {
shepherd . fs . readFile ( ` ${ shepherd . komodoDir } /komodo.conf ` , 'utf8' , ( err , data ) => {
fs . readFile ( ` ${ shepherd . komodoDir } /komodo.conf ` , 'utf8' , ( err , data ) => {
const _ maxconVal = limit ? 1 : 10 ;
const _ maxconVal = limit ? 1 : 10 ;
if ( err ) {
if ( err ) {
@ -37,7 +39,7 @@ module.exports = (shepherd) => {
data = ` ${ data } \n maxconnections= ${ _ maxconVal } \n ` ;
data = ` ${ data } \n maxconnections= ${ _ maxconVal } \n ` ;
}
}
shepherd . fs . writeFile ( ` ${ shepherd . komodoDir } /komodo.conf ` , data , ( err ) => {
fs . writeFile ( ` ${ shepherd . komodoDir } /komodo.conf ` , data , ( err ) => {
if ( err ) {
if ( err ) {
shepherd . log ( ` error writing ${ shepherd . komodoDir } /komodo.conf maxconnections= ${ _ maxconVal } ` ) ;
shepherd . log ( ` error writing ${ shepherd . komodoDir } /komodo.conf maxconnections= ${ _ maxconVal } ` ) ;
resolve ( false ) ;
resolve ( false ) ;