@@ -13,26 +13,35 @@ import (
1313
1414var wg sync.WaitGroup
1515
16+ // main starts all the submodules containing the emulators.
17+ // It is the first function called when the application is run.
18+ // It also acts as an orchestrator, which dictates the functioning of the application.
1619func main () {
17-
1820 if environ .Getenv ("SERVICES" , "" ) == "" {
19- wg .Add (1 )
21+ wg .Add (1 ) // add a goroutine to the stack, blocking until all services are up.
22+
23+ //----------------
24+ // Add here all the services that must be run by default if either there is no
25+ // environment file or variables which define this behaviour otherwise.
26+ //----------------
2027 go telnet_serv ()
2128 go http_serv ()
22- go ssh_serv () //Starts SSH Server
29+ go ssh_serv ()
2330 //go trydy_proxy_serv()
24- wg .Wait ()
25- } else {
31+ //----------------
2632
33+ wg .Wait () // wait until the goroutines call Done or are over.
34+ } else {
35+ // TODO: add the logic to the loop.
2736 }
2837}
2938
39+ /*
40+ Print to the console if the server successfully started
41+ @service: the name of the service
42+ @out: the integer result of the server started, 1 or 0 , where 0 is a falsy value.
43+ */
3044func serv_out (service string , out int ) {
31- /*
32- Print to the console if the server successfully started
33- @service: the name of the service
34- @out: the integer result of the server started, 1 or 0 , where 0 is a falsy value.
35- */
3645
3746 if out > 0 {
3847 fmt .Printf ("%s Server Started" , service )
@@ -41,18 +50,18 @@ func serv_out(service string, out int) {
4150 }
4251}
4352
53+ /*Start SSH server*/
4454func ssh_serv () {
45- /*Start SSH server*/
4655 sshd .SSHServer ()
4756}
4857
58+ /* Start Telnet server */
4959func telnet_serv () {
50- /* Start Telnet server */
5160 telnetd .TelnetServer ()
5261}
5362
63+ /* Start HTTP server */
5464func http_serv () {
55- /* Start HTTP server */
5665 httpd .HttpServer ()
5766}
5867
0 commit comments