77 lines
2.6 KiB
Markdown
77 lines
2.6 KiB
Markdown
|
|
# Worker
|
|
|
|
Remote gRPC/jsonRPC for bootstrap deployments, control operation systems and etc.
|
|
|
|
## Remote execution of command over gRPC/jsonRPC
|
|
|
|
###
|
|
|
|
```
|
|
|
|
$ ./workerd -daemon
|
|
|
|
$ tail -f workerd.log
|
|
2023-10-03T21:10:27+02:00 info <object:server> [Build server]
|
|
2023-10-03T21:10:28+02:00 debug <object:wservice> [Build service]
|
|
2023-10-03T21:10:28+02:00 debug <object:server> [Server configuration:
|
|
wservice:
|
|
port: 9101
|
|
gservice:
|
|
port: 9202
|
|
auth:
|
|
username: worker
|
|
password: worker
|
|
hostname: localhost
|
|
debug: false
|
|
build: 2023-10-03-1009
|
|
logfile: workerd.log
|
|
runfile: workerd.pid
|
|
daemon: false
|
|
|
|
]
|
|
2023-10-03T21:10:28+02:00 info <object:server> [Running server as user ziggi]
|
|
2023-10-03T21:10:28+02:00 info <object:gservice> [Service run]
|
|
2023-10-03T21:10:28+02:00 debug <object:wservice> [The route is registered: POST /api/v1/status/get]
|
|
2023-10-03T21:10:28+02:00 debug <object:wservice> [The route is registered: POST /api/v1/command/exec]
|
|
2023-10-03T21:10:28+02:00 info <object:wservice> [Service listening at 9101 port]
|
|
2023-10-03T21:10:28+02:00 info <object:gservice> [Service listening at [::]:9202]
|
|
2023-10-03T21:12:55+02:00 debug <object:gservice> [Called unary interceptor with method: /workercontrol.Control/ExecCommand]
|
|
2023-10-03T21:12:55+02:00 debug <object:gservice> [Reqest username: [worker]]
|
|
2023-10-03T21:12:55+02:00 debug <object:gservice> [Reqest password: [worker]]
|
|
2023-10-03T21:12:55+02:00 debug <object:gservice> [Request: {"command":"ls","args":["-l"],"workdir":"/var"}]
|
|
2023-10-03T21:12:55+02:00 debug <object:ghandler> [Handle execCommand request]
|
|
2023-10-03T21:12:55+02:00 debug <object:logic> [Exec command: [wd:/var] /bin/ls -l ]
|
|
|
|
```
|
|
|
|
## Client side
|
|
|
|
```
|
|
$ ./workerctl -host 127.0.0.1 execCommand -workdir /var ls -l
|
|
error: false
|
|
result:
|
|
stdout: |
|
|
total 48
|
|
drwxr-xr-x 2 root root 4096 Oct 3 09:19 backups
|
|
drwxr-xr-x 18 root root 4096 Apr 5 18:58 cache
|
|
drwxr-xr-x 3 root root 4096 Apr 25 13:31 db
|
|
drwxr-xr-x 82 root root 4096 Sep 7 13:12 lib
|
|
drwxrwsr-x 2 root staff 4096 Sep 19 2020 local
|
|
lrwxrwxrwx 1 root root 11 Feb 27 2021 lock -> ../run/lock
|
|
drwxr-xr-x 29 root root 4096 Oct 4 10:16 log
|
|
drwxrwsr-x 2 root mail 4096 Apr 5 19:00 mail
|
|
drwxr-xr-x 4 root root 4096 Aug 9 23:07 openebs
|
|
drwxr-xr-x 2 root root 4096 Sep 26 2020 opt
|
|
lrwxrwxrwx 1 root root 6 Feb 27 2021 run -> ../run
|
|
drwxr-xr-x 8 root root 4096 Apr 12 2021 spool
|
|
drwxrwxrwt 67 root root 4096 Oct 4 12:12 tmp
|
|
drwxr-xr-x 3 root root 4096 Mar 2 2021 www
|
|
stderr: ""
|
|
exitcode: 0
|
|
success: true
|
|
command: /bin/ls -l
|
|
workdir: /var
|
|
```
|
|
|