Ftth_task.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace FD3\Services;
  3. use Docker\Composer\FileFormat;
  4. use FD3\Release;
  5. class Ftth_task extends InitialService
  6. {
  7. /**
  8. * @var int ip server
  9. */
  10. protected $ip_server = 20;
  11. /**
  12. * Ftth_tasklogger_worker constructor.
  13. */
  14. public function __construct()
  15. {
  16. $this
  17. ->setHelp("Modulo de logs de tareas del ftth")
  18. ->setHostEnv(false)
  19. ->setVarEnv([])
  20. ->setOauth(false)
  21. ->setRequired(false)
  22. ->setDepends(['ftth']);
  23. }
  24. /**
  25. * Add config
  26. * @throws \Docker\Composer\ServiceNotFoundException
  27. */
  28. public function add()
  29. {
  30. $module = $this->getModuleName();
  31. $initial = $this->getInitialName();
  32. $version = "latest";
  33. $registry = "";
  34. extract($this->getConfigVar());
  35. if ($this->getRelease()->needInstallModule($module)) {
  36. $this->getComposer()->addService($module)
  37. ->image($registry . "fd3/$initial:" . $version);
  38. if ($this->getProduction() === false) {
  39. $this->getComposer()->service($module)
  40. ->build("./$initial/")
  41. ->addVolumes("./$initial/", "/opt/$initial/")
  42. ->addVolumes("./netmiko/", "/opt/netmiko/")
  43. ->addVolumes("./connect/", "/usr/bin/connect/");
  44. }
  45. $this->getComposer()->service($module)
  46. ->hostname($module)
  47. ->command("bin/console rabbitmq:consumer flowdat_tasklogger")
  48. ->restart($this->getRelease()->_docker_restart_task)
  49. ->addEnv_file($this->getRelease()->_running_env)
  50. ->addEnv_file($this->getRelease()->_host_env)
  51. ->addEnv_file("$initial." . $this->getRelease()->_host_env)
  52. ->addEnviroment("AMQP_KEY", "$initial")
  53. ->addVolumes("./backups-config", "/opt/ftth/web/backups-config")
  54. ->addVolumes("/etc/localtime:/etc/localtime:ro")
  55. ->addVolumes("./hosts:/etc/hosts")
  56. ->network($this->getRelease()->_network_name)->ipv4_address($this->generateIP());
  57. $this->addLink(new Mysql(), $module)
  58. ->addLink(new Base(), $module)
  59. ->addLinkNginx(new Base(), $module);
  60. }
  61. }
  62. }