main.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package main
  2. import (
  3. "log"
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. "aytechnology.us/gomatlab/mod/aroz"
  8. "aytechnology.us/gomatlab/mod/server"
  9. )
  10. //MCServer should not be exported
  11. var MCServer *server.Handler
  12. var (
  13. handler *aroz.ArozHandler
  14. )
  15. //Kill signal handler. Do something before the system the core terminate.
  16. func SetupCloseHandler() {
  17. c := make(chan os.Signal, 2)
  18. signal.Notify(c, os.Interrupt, syscall.SIGTERM)
  19. go func() {
  20. <-c
  21. log.Println("\r- Shutting down demo module.")
  22. //Do other things like close database or opened files
  23. os.Exit(0)
  24. }()
  25. }
  26. func main() {
  27. //AROZOS
  28. //If you have other flags, please add them here
  29. //Start the aoModule pipeline (which will parse the flags as well). Pass in the module launch information
  30. handler = aroz.HandleFlagParse(aroz.ServiceInfo{
  31. Name: "Octave",
  32. Desc: "GO Octave",
  33. Group: "Development",
  34. IconPath: "gooctave/icon.png",
  35. Version: "0.0.1",
  36. //You can define any path before the actualy html file. This directory (in this case demo/ ) will be the reverse proxy endpoint for this module
  37. StartDir: "gooctave/index.html",
  38. SupportFW: true,
  39. LaunchFWDir: "gooctave/index.html",
  40. SupportEmb: true,
  41. LaunchEmb: "gooctave/404.html",
  42. InitFWSize: []int{720, 480},
  43. InitEmbSize: []int{720, 480},
  44. SupportedExt: []string{},
  45. })
  46. MCServer = server.NewHandler()
  47. MCServer.StartService("./tmp/")
  48. //init the image Handler
  49. MCServer.SendCommand("figure(\"visible\", \"off\")")
  50. MCServer.SendCommand("plot(0,0)")
  51. //MCServer.SendCommand("figure(\"visible\", \"on\")")
  52. SetupCloseHandler()
  53. //Any log println will be shown in the core system via STDOUT redirection. But not STDIN.
  54. log.Println("gooctave module started. Listening on " + handler.Port)
  55. webServer("./webroot/", "./tmp/", handler.Port)
  56. MCServer.Wait()
  57. }