package Ġcz . v ut br . fit . k not . entic ing . management . shell Ċ Ċ import Ġcz . v ut br . fit . k not . entic ing . dto . Component Info Ċ import Ġcz . v ut br . fit . k not . entic ing . dto . annotation . Incomplete Ċ import Ġcz . v ut br . fit . k not . entic ing . dto . config . dsl . Deployment Configuration Ċ import Ġcz . v ut br . fit . k not . entic ing . dto . utils . to Dto Ċ import Ġcz . v ut br . fit . k not . entic ing . log . ComponentType Ċ import Ġcz . v ut br . fit . k not . entic ing . management . model . Mg 4 j File Ċ import Ġcz . v ut br . fit . k not . entic ing . mx . Server Probe ĊĊ Ċ suspend Ġfun ĠShell Command Executor . start Component ( component : ĠComponent Info , Ġdeployment Configuration : ĠDeployment Configuration ): ĠString Ġ= Ġwhen Ġ( component . type ) Ġ{ ĊĠĠĠ ĠComponent Type . INDEX _ SERVER Ġ-> ĠstartIndex Server ( component . server Address , Ġdeployment Configuration . repository , Ġdeployment Configuration . configuration Script , Ġcomponent . port , Ġdeployment Configuration . build Id ) ĊĠĠĠ ĠComponent Type . WEB SERVER Ġ-> Ġstart Web server ( component . server Address , Ġdeployment Configuration . repository , Ġdeployment Configuration . configuration Script , Ġcomponent . port , Ġdeployment Configuration . build Id ) ĊĠĠĠ ĠComponent Type . MANAGE MENT _ SERVER Ġ-> Ġstart Management Service ( component . server Address , Ġdeployment Configuration . repository , Ġdeployment Configuration . configuration Script , Ġcomponent . port , Ġdeployment Configuration . build Id ) ĊĠĠĠ Ġelse Ġ-> Ġerror (" Cannot Ġstart Ġcomponent Ġof Ġtype Ġ${ component . type }") Ċ } Ċ Ċ suspend Ġfun ĠShell Command Executor . kill Component ( component : ĠComponent Info ): ĠString Ġ= Ġwhen Ġ( component . type ) Ġ{ ĊĠĠĠ ĠComponent Type . INDEX _ SERVER Ġ-> Ġkill Index Server ( component . server Address ) ĊĠĠĠ ĠComponent Type . WEB SERVER Ġ-> Ġkill Web server ( component . server Address ) ĊĠĠĠ ĠComponent Type . MANAGE MENT _ SERVER Ġ-> Ġkill Management Service ( component . server Address ) ĊĠĠĠ Ġelse Ġ-> Ġerror (" Cannot Ġstart Ġcomponent Ġof Ġtype Ġ${ component . type }") Ċ } Ċ Ċ suspend Ġfun ĠShell Command Executor . local Build ( build Id : ĠString , Ġent icing Home : ĠString ): ĠString Ġ{ ĊĠĠĠ Ġreturn Ġthis . execute ( Simple Command ("$ entic ing Home / bin / local - build Ġ$ build Id "), Ġworking Directory Ġ= Ġent icing Home ) Ċ } Ċ Ċ suspend Ġfun ĠShell Command Executor . copy J ars ( server : ĠString , Ġlocal Repository : ĠString , Ġremote Repository : ĠString , Ġusername : ĠString ? Ġ= Ġnull ) Ġ= Ġthis . execute ( Simple Command (" scp Ġ$ local Repository / lib /*. jar Ġ${ username Ġ?: Ġthis . username }@ $ server :$ remote Repository / lib ")) Ċ Ċ @ Incomplete (" specify Ġports ...") Ċ suspend Ġfun ĠShell Command Executor . start Web server ( server : ĠString , Ġent icing Home : ĠString , Ġconfig File : ĠString , Ġport : ĠInt , Ġbuild Id : ĠString , Ġusername : ĠString ? Ġ= Ġnull ) Ġ= Ġthis . execute ( Ssh Command ( username ĊĠĠĠĠĠĠĠ Ġ?: Ġthis . username , Ġserver , ĊĠĠĠĠĠĠĠ ĠStart Screen Command (" entic ing - webserver ", ĠSimple Command ("$ entic ing Home / bin / webserver Ġ$ build Id Ġ$ configFile Ġ$ server Ġ-- server . port =$ port ")) )) Ċ Ċ suspend Ġfun ĠShell Command Executor . kill Web server ( server : ĠString , Ġusername : ĠString ? Ġ= Ġnull ) Ġ= ĊĠĠĠĠĠĠĠ Ġthis . execute ( Ssh Command ( username ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ?: Ġthis . username , Ġserver , ĠKill Screen Command (" entic ing - webserver ")), Ġcheck Return Code Ġ= Ġfalse ) Ċ Ċ suspend Ġfun ĠShell Command Executor . start Management Service ( server : ĠString , Ġent icing Home : ĠString , Ġconfig File : ĠString , Ġport : ĠInt , Ġbuild Id : ĠString , Ġusername : ĠString ? Ġ= Ġnull ) Ġ= Ġthis . execute ( Ssh Command ( username ĊĠĠĠĠĠĠĠ Ġ?: Ġthis . username , Ġserver , ĊĠĠĠĠĠĠĠ ĠStart Screen Command (" entic ing - management ", ĠSimple Command ("$ entic ing Home / bin / management - service Ġ$ build Id Ġ$ configFile Ġ$ server Ġ-- debug . runner . start = false Ġ-- server . port =$ port ")) )) Ċ Ċ suspend Ġfun ĠShell Command Executor . kill Management Service ( server : ĠString , Ġusername : ĠString ? Ġ= Ġnull ) Ġ= ĊĠĠĠĠĠĠĠ Ġthis . execute ( Ssh Command ( username ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ?: Ġthis . username , Ġserver , ĠKill Screen Command (" entic ing - management ")), Ġcheck Return Code Ġ= Ġfalse ) Ċ Ċ suspend Ġfun ĠShell Command Executor . startIndex Server ( server : ĠString , Ġent icing Home : ĠString , Ġconfig File : ĠString , Ġport : ĠInt , Ġbuild Id : ĠString , Ġusername : ĠString ? Ġ= Ġnull ) Ġ= Ġthis . execute ( Ssh Command ( username ĊĠĠĠĠĠĠĠ Ġ?: Ġthis . username , Ġserver , ĊĠĠĠĠĠĠĠ ĠStart Screen Command (" entic ing - index - server ", ĠSimple Command ("$ entic ing Home / bin / index - server Ġ$ build Id Ġ$ configFile Ġ$ server Ġ-- server . port =$ port ")) )) Ċ Ċ suspend Ġfun ĠShell Command Executor . kill Index Server ( server : ĠString , Ġusername : ĠString ? Ġ= Ġnull ) Ġ= ĊĠĠĠĠĠĠĠ Ġthis . execute ( Ssh Command ( username ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ?: Ġthis . username , Ġserver , ĠKill Screen Command (" entic ing - index - server ")), Ġcheck Return Code Ġ= Ġfalse ) Ċ Ċ suspend Ġfun ĠShell Command Executor . preprocess Collections ( server : ĠString , Ġent icing Home : ĠString , Ġconfig File : ĠString , Ġbuild Id : ĠString , Ġusername : ĠString ? Ġ= Ġnull ) Ġ= Ġthis . execute ( ĊĠĠĠĠĠĠĠ ĠSsh Command ( username Ġ?: Ġthis . username , Ġserver , Ċ // ĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠSimple Command (" screen Ġ- S Ġindex - builder Ġ$ entic ing Home / bin / index - builder Ġ$ configFile Ġ$ server "), Ġforce Pseudo Terminal Ġ= Ġtrue ), Ġlog Prefix Ġ= Ġserver ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠSimple Command ("$ entic ing Home / bin / index - builder Ġ$ build Id Ġ$ configFile Ġ$ server ")), Ġlog Prefix Ġ= Ġserver ) Ċ Ċ suspend Ġfun ĠShell Command Executor . probe Server ( server : ĠString , Ġent icing Home : ĠString , Ġbuild Id : ĠString , Ġusername : ĠString ? Ġ= Ġnull ) Ġ= Ġthis . execute ( ĊĠĠĠĠĠĠĠ ĠSsh Command ( username ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ?: Ġthis . username , Ġserver , ĠSimple Command ("$ entic ing Home / bin / server - probe Ġ$ build Id "), Ġforce Pseudo Terminal Ġ= Ġtrue ) Ċ ). to Dto < Server Probe . Info >() Ċ Ċ /** Ċ Ġ* Ġconnects Ġto Ġthe Ġgiven Ġserver , Ġgit Ġpull s Ġfor Ġnew Ġchanges Ġand Ġbuilds Ġthe Ġproject Ċ Ġ*/ Ċ suspend Ġfun ĠShell Command Executor . pull And Build ( source Server : ĠString , Ġrepository : ĠString , Ġusername : ĠString ? Ġ= Ġnull ) Ġ{ ĊĠĠĠ Ġval Ġlocal Ġ= ĠSimple Command (" cd Ġ$ repository ") Ġand ĠSimple Command (" git Ġpull ") Ġand ĠSimple Command (" gradle Ġbuild All ") ĊĠĠĠ Ġthis . execute ( Ssh Command ( username Ġ?: Ġthis . username , Ġsource Server , Ġlocal )) Ċ } Ċ Ċ /** Ċ Ġ* Ġcopies Ġfiles Ġfrom Ġsource Ġserver Ġto Ġthe Ġdestination Ġserver Ġusing Ġsc p Ċ Ġ*/ Ċ suspend Ġfun ĠShell Command Executor . copy Files ( source Server : ĠString , Ġfiles : ĠList < Mg 4 j File >, Ġdestination Server : ĠString , Ġdestination Directory : ĠString , Ġusername : ĠString ? Ġ= Ġnull ) Ġ{ ĊĠĠĠ Ġthis . execute ( Ssh Command ( username ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ?: Ġthis . username , Ġsource Server , ĠSimple Command (" scp Ġ${ files . join ToString (" Ġ") Ġ{ Ġit . path Ġ}} Ġ${ username Ġ?: Ġthis . username }@ $ destination Server :$ destination Directory "))) Ċ } Ċ Ċ /** Ċ Ġ* Ġcreates Ġa Ġdirectory Ġon Ġa Ġspecified Ġserver Ġusing Ġmkdir Ġ- p Ċ Ġ*/ Ċ suspend Ġfun ĠShell Command Executor . create Remote Directory ( server : ĠString , Ġpath : ĠString , Ġusername : ĠString ? Ġ= Ġnull ) Ġ{ ĊĠĠĠ Ġthis . execute ( Ssh Command ( username Ġ?: Ġthis . username , Ġserver , ĠSimple Command (" mkdir Ġ- p Ġ$ path "))) Ċ } Ċ Ċ private Ġval Ġwhitespace Regex Ġ= Ġ""" \ s + """. to Regex () Ċ Ċ private Ġval Ġsize Column Ġ= Ġ 4 Ċ private Ġval Ġpath Column Ġ= Ġ 8 Ċ Ċ /** Ċ Ġ* ĠLoad Ġmg 4 j Ġfiles Ġlocated Ġin Ġa Ġgiven Ġdirectory Ċ Ġ*/ Ċ suspend Ġfun ĠShell Command Executor . load Mg 4 j Files ( server : ĠString , Ġdirectory : ĠString , Ġfile Limit : ĠInt Ġ= ĠInt . MAX _ VALUE , Ġusername : ĠString ? Ġ= Ġnull ): ĠList < Mg 4 j File > Ġ{ ĊĠĠĠ Ġval Ġstdout Ġ= Ġthis . dump Mg j 4 Files ( server , Ġdirectory , Ġfile Limit , Ġusername Ġ?: Ġthis . username ) ĊĠĠĠ Ġreturn Ġstdout . split ("\ n "). map NotNull Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġline Ġ= Ġit . split ( whitespace Regex ) ĊĠĠĠĠĠĠĠ Ġif Ġ( line . size Ġ< Ġ 9 ) Ġreturn @ map NotNull Ġnull ĊĠĠĠĠĠĠĠ ĠM g 4 j File ( line [ path Column ], Ġline [ size Column ]. to Long OrNull () Ġ?: Ġreturn @ map NotNull Ġnull ) ĊĠĠĠ Ġ} Ċ } ĊĊ Ċ suspend Ġfun ĠShell Command Executor . recursive Remove ( server : ĠString , Ġdirectory : ĠString , Ġusername : ĠString ? Ġ= Ġnull ) Ġ{ ĊĠĠĠ Ġthis . execute ( Ssh Command ( username ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ?: Ġthis . username , Ġserver , ĠSimple Command (" rm Ġ- rf Ġ$ directory ")), Ġcheck Return Code Ġ= Ġfalse ) Ċ } Ċ Ċ suspend Ġfun ĠShell Command Executor . load Files ( server : ĠString , Ġdirectory : ĠString , Ġusername : ĠString ? Ġ= Ġnull ): ĠList < String > Ġ{ ĊĠĠĠ Ġval Ġstdout Ġ= Ġthis . execute ( Ssh Command ( username ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ?: Ġthis . username , Ġserver , ĠSimple Command (" ls Ġ- l Ġ$ directory ")), Ġprint Stdout Ġ= Ġfalse , Ġcheck Return Code Ġ= Ġfalse ) ĊĠĠĠ Ġreturn Ġstdout . split ("\ n "). map NotNull Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġline Ġ= Ġit . split ( whitespace Regex ) ĊĠĠĠĠĠĠĠ Ġif Ġ( line . size Ġ< Ġ 9 ) Ġreturn @ map NotNull Ġnull ĊĠĠĠĠĠĠĠ Ġline [ path Column ] ĊĠĠĠ Ġ} Ċ } ĊĊ Ċ /** Ċ Ġ* ĠDump s Ġspecified Ġdirectory Ġfor Ġmg 4 j Ġfiles Ġusing Ġls Ċ Ġ*/ Ċ private Ġsuspend Ġfun ĠShell Command Executor . dump Mg j 4 Files ( server : ĠString , Ġdirectory : ĠString , Ġfile Limit : ĠInt , Ġusername : ĠString ? Ġ= Ġnull ) Ġ= ĊĠĠĠĠĠĠĠ Ġthis . execute ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠSsh Command ( username Ġ?: Ġthis . username , Ġserver , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠSimple Command (" ls Ġ- l Ġ$ directory /*. mg 4 j Ġ| Ġhead Ġ- n Ġ$ file Limit ")), Ġprint Stdout Ġ= Ġfalse , Ġcheck Return Code Ġ= Ġfalse )