@@ -32,6 +32,7 @@ protected function configure(): void {
3232 $ this ->setName ('app_api:daemon:register ' );
3333 $ this ->setDescription ('Register daemon config for ExApp deployment ' );
3434
35+ // todo: add docs
3536 $ this ->addArgument ('name ' , InputArgument::REQUIRED );
3637 $ this ->addArgument ('display-name ' , InputArgument::REQUIRED );
3738 $ this ->addArgument ('accepts-deploy-id ' , InputArgument::REQUIRED );
@@ -42,13 +43,17 @@ protected function configure(): void {
4243 // daemon-config settings
4344 $ this ->addOption ('net ' , null , InputOption::VALUE_REQUIRED , 'DeployConfig, the name of the docker network to attach App to ' );
4445 $ this ->addOption ('haproxy_password ' , null , InputOption::VALUE_REQUIRED , 'AppAPI Docker Socket Proxy password for HAProxy Basic auth ' );
45-
4646 $ this ->addOption ('compute_device ' , null , InputOption::VALUE_REQUIRED , 'Compute device for GPU support (cpu|cuda|rocm) ' );
47-
4847 $ this ->addOption ('set-default ' , null , InputOption::VALUE_NONE , 'Set DaemonConfig as default ' );
49-
50- $ this ->addUsage ('local_docker "Docker local" "docker-install" "http" "/var/run/docker.sock" "http://nextcloud.local" --net=nextcloud ' );
51- $ this ->addUsage ('local_docker "Docker local" "docker-install" "http" "/var/run/docker.sock" "http://nextcloud.local" --net=nextcloud --set-default --compute_device=cuda ' );
48+ $ this ->addOption ('harp ' , null , InputOption::VALUE_NONE , 'Set daemon to use HaRP for all docker and exapp communication ' );
49+ $ this ->addOption ('harp_frp_address ' , null , InputOption::VALUE_REQUIRED , '[host]:[port] of the HaRP FRP server, default host is same as HaRP host and port is 8782 ' );
50+ $ this ->addOption ('harp_shared_key ' , null , InputOption::VALUE_REQUIRED , 'HaRP shared key for secure communication between HaRP and AppAPI ' );
51+
52+ $ this ->addUsage ('manual_install "Manual Install" "manual-install" "http" null "http://nextcloud.local" ' );
53+ $ this ->addUsage ('local_docker "Docker Local" "docker-install" "http" "/var/run/docker.sock" "http://nextcloud.local" --net=nextcloud ' );
54+ $ this ->addUsage ('local_docker "Docker Local" "docker-install" "http" "/var/run/docker.sock" "http://nextcloud.local" --net=nextcloud --set-default --compute_device=cuda ' );
55+ $ this ->addUsage ('docker_install "Docker Socket Proxy" "docker-install" "http" "nextcloud-appapi-dsp:2375" "http://nextcloud.local" --net=nextcloud --set-default --compute_device=cuda ' );
56+ $ this ->addUsage ('harp_install "Harp Install" "docker-install" "http" "nextcloud-appapi-harp:8780" "http://nextcloud.local" --harp --harp_shared_key "some_very_secure_password" --set-default --compute_device=cuda ' );
5257 }
5358
5459 protected function execute (InputInterface $ input , OutputInterface $ output ): int {
@@ -58,28 +63,47 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5863 $ protocol = $ input ->getArgument ('protocol ' );
5964 $ host = $ input ->getArgument ('host ' );
6065 $ nextcloudUrl = $ input ->getArgument ('nextcloud_url ' );
61-
62- $ deployConfig = [
63- 'net ' => $ input ->getOption ('net ' ) ?? 'host ' ,
64- 'nextcloud_url ' => $ nextcloudUrl ,
65- 'haproxy_password ' => $ input ->getOption ('haproxy_password ' ) ?? '' ,
66- 'computeDevice ' => $ this ->buildComputeDevice ($ input ->getOption ('compute_device ' ) ?? 'cpu ' ),
67- ];
66+ $ isHarp = $ input ->getOption ('harp ' ) !== null ;
6867
6968 if (($ protocol !== 'http ' ) && ($ protocol !== 'https ' )) {
7069 $ output ->writeln ('Value error: The protocol must be `http` or `https`. ' );
7170 return 1 ;
7271 }
73- if (( $ acceptsDeployId === 'manual-install ' ) && ( $ protocol !== 'http ' ) ) {
72+ if ($ acceptsDeployId === 'manual-install ' && $ protocol !== 'http ' ) {
7473 $ output ->writeln ('Value error: Manual-install daemon supports only `http` protocol. ' );
7574 return 1 ;
7675 }
76+ // todo:
77+ if ($ acceptsDeployId === 'manual-install ' && $ isHarp ) {
78+ $ output ->writeln ('Value error: Manual-install daemon does not support HaRP. ' );
79+ return 1 ;
80+ }
81+ if ($ isHarp && !$ input ->getOption ('harp_shared_key ' )) {
82+ $ output ->writeln ('Value error: HaRP enabled daemon requires `harp_shared_key` option. ' );
83+ return 1 ;
84+ }
85+ if ($ isHarp && !$ input ->getOption ('harp_frp_address ' )) {
86+ $ output ->writeln ('Value error: HaRP enabled daemon requires `harp_frp_address` option. ' );
87+ return 1 ;
88+ }
7789
7890 if ($ this ->daemonConfigService ->getDaemonConfigByName ($ name ) !== null ) {
7991 $ output ->writeln (sprintf ('Skip registration, as daemon config `%s` already registered. ' , $ name ));
8092 return 0 ;
8193 }
8294
95+ $ secret = $ isHarp
96+ ? $ input ->getOption ('harp_shared_key ' )
97+ : $ input ->getOption ('haproxy_password ' ) ?? '' ;
98+
99+ $ deployConfig = [
100+ 'net ' => $ input ->getOption ('net ' ) ?? 'host ' ,
101+ 'nextcloud_url ' => $ nextcloudUrl ,
102+ 'haproxy_password ' => $ secret ,
103+ 'computeDevice ' => $ this ->buildComputeDevice ($ input ->getOption ('compute_device ' ) ?? 'cpu ' ),
104+ 'harp ' => $ isHarp ,
105+ ];
106+
83107 $ daemonConfig = $ this ->daemonConfigService ->registerDaemonConfig ([
84108 'name ' => $ name ,
85109 'display_name ' => $ displayName ,
0 commit comments