Enable hooks within tusd container unable to create listener error

i’m trying to enable hooks, so i ran tusd --hooks-dir ./tusd-hooks --upload-dir=./tusd-data/data
with in the tusd container and getting the following error unable to create listener, blind address already in use. of course tusd is on port 1080. Any ideas would be much appreciated?

[tusd] 2023/03/16 07:34:08.343102 Using ‘/srv/tusd-hooks/data’ as directory storage.
[tusd] 2023/03/16 07:34:08.345033 Using 0.00MB as maximum size.
[tusd] 2023/03/16 07:34:08.345077 Using ‘/srv/tusd-hooks/tusd-hooks’ for hooks
[tusd] 2023/03/16 07:34:08.345089 Enabled hook events: pre-create, post-create, post-receive, post-terminate, post-finish
[tusd] 2023/03/16 07:34:08.345141 Using 0.0.0.0:1080 as address to listen.
[tusd] 2023/03/16 07:34:08.345157 Using /files/ as the base path.
[tusd] 2023/03/16 07:34:08.345252 Using /metrics as the metrics path.
[tusd] 2023/03/16 07:34:08.345344 Supported tus extensions: creation,creation-with-upload,termination,concatenation,creation-defer-length
[tusd] 2023/03/16 07:34:08.374574 Unable to create listener: listen tcp 0.0.0.0:1080: bind: address already in use

Are you running two tusd processes inside the same containers? You do not need two processes for using hooks. The tusd process itself is able to listen for uploads and handle the hooks without a second process. You should use one tusd process and add the hooks flags to its command line.

Hi Marius,
thats what i was trying to do. i have tus running as a container and i though i was trying to add the hook flags by running tusd --hooks-dir ./tusd-hooks.
ended up adding a command in the docker-compose to add the flag but now running into other errors

[tusd] 2023/03/16 14:13:32.531622 event=“ResponseOutgoing” status=“500” method=“POST” path=“” error="pre-create hook failed: fork/exec /srv/tusd-hooks/pre-create: permission denied
" requestId=“66f6678f-8cfe-4b6e-a7cc-f2ec44b9b0e1”
tried to change the permissions on the pre-create file

if i delete this pre-create script so there are no hooks, restart tusd server, see logs and the upload fails
with unexpecrted response while uploading chunk,originated from request

[tusd] 2023/03/16 13:21:59.755054 event=“HookInvocationFinish” type=“pre-create” id=“”
[tusd] 2023/03/16 13:21:59.755288 event=“UploadCreated” id=“d9030bd71cc50ea816c0064f61b0016d” size=“11986” url=“http://demo.nalytics.net/files/d9030bd71cc50ea816c0064f61b0016d
[tusd] 2023/03/16 13:21:59.755320 event=“ResponseOutgoing” status=“201” method=“POST” path=“” requestId=“ac70b44b-15b5-4816-b2cf-6adec47e1286”
[tusd] 2023/03/16 13:21:59.755348 event=“HookInvocationStart” type=“post-create” id=“d9030bd71cc50ea816c0064f61b0016d”
[tusd] 2023/03/16 13:21:59.756113 event=“HookInvocationFinish” type=“post-create” id=“d9030bd71cc50ea816c0064f61b0016d”
[tusd] 2023/03/16 13:22:00.771114 event=“RequestIncoming” method=“POST” path=“” requestId=“ea09f7f6-3152-4b49-9f75-a1ce6cad0180”
[tusd] 2023/03/16 13:22:00.771171 event=“HookInvocationStart” type=“pre-create” id=“”
[tusd] 2023/03/16 13:22:00.771586 event=“HookInvocationFinish” type=“pre-create” id=“”
[tusd] 2023/03/16 13:22:00.771790 event=“UploadCreated” id=“ccef99d28b50fddb87fd3dfbfc96a35c” size=“11986” url=“http://demo.nalytics.net/files/ccef99d28b50fddb87fd3dfbfc96a35c
[tusd] 2023/03/16 13:22:00.771819 event=“ResponseOutgoing” status=“201” method=“POST” path=“” requestId=“ea09f7f6-3152-4b49-9f75-a1ce6cad0180”
[tusd] 2023/03/16 13:22:00.772040 event=“HookInvocationStart” type=“post-create” id=“ccef99d28b50fddb87fd3dfbfc96a35c”
[tusd] 2023/03/16 13:22:00.772650 event=“HookInvocationFinish” type=“post-create” id=“ccef99d28b50fddb87fd3dfbfc96a35c”
[tusd] 2023/03/16 13:22:03.787171 event=“RequestIncoming” method=“POST” path=“” requestId=“6a8e5463-63ba-4850-82c5-86436f1a068b”
[tusd] 2023/03/16 13:22:03.787206 event=“HookInvocationStart” type=“pre-create” id=“”
[tusd] 2023/03/16 13:22:03.787609 event=“HookInvocationFinish” type=“pre-create” id=“”
[tusd] 2023/03/16 13:22:03.787802 event=“UploadCreated” id=“3460273e0e0a5b704ad3cac11711f73b” size=“11986” url=“http://demo.nalytics.net/files/3460273e0e0a5b704ad3cac11711f73b
[tusd] 2023/03/16 13:22:03.787828 event=“ResponseOutgoing” status=“201” method=“POST” path=“” requestId=“6a8e5463-63ba-4850-82c5-86436f1a068b”
[tusd] 2023/03/16 13:22:03.787955 event=“HookInvocationStart” type=“post-create” id=“3460273e0e0a5b704ad3cac11711f73b”
[tusd] 2023/03/16 13:22:03.788436 event=“HookInvocationFinish” type=“post-create” id=“3460273e0e0a5b704ad3cac11711f73b”
[tusd] 2023/03/16 13:22:08.805348 event=“RequestIncoming” method=“POST” path=“” requestId=“9833358d-1fd0-4135-a978-d92853730a31”
[tusd] 2023/03/16 13:22:08.805429 event=“HookInvocationStart” type=“pre-create” id=“”
[tusd] 2023/03/16 13:22:08.805860 event=“HookInvocationFinish” type=“pre-create” id=“”
[tusd] 2023/03/16 13:22:08.806026 event=“UploadCreated” id=“d9814d184fcdb0821888ce96d76d976a” size=“11986” url=“http://demo.nalytics.net/files/d9814d184fcdb0821888ce96d76d976a
[tusd] 2023/03/16 13:22:08.806059 event=“ResponseOutgoing” status=“201” method=“POST” path=“” requestId=“9833358d-1fd0-4135-a978-d92853730a31”
[tusd] 2023/03/16 13:22:08.806164 event=“HookInvocationStart” type=“post-create” id=“d9814d184fcdb0821888ce96d76d976a”
[tusd] 2023/03/16 13:22:08.806597 event=“HookInvocationFinish” type=“post-create” id=“d9814d184fcdb0821888ce96d76d976a”

This error means that the file pre-create is not executable. You must make sure that the file permissions of the hook file allow it to be executed inside the Docker container. Usually it is enough to run chmod +x pre-create, but maybe there is more required for Docker containers. Unfortunately, I am not Docker expert, but you should find something about this in other forums.

I don’t see any error in these logs. However, they only show the creation of multiple uploads, but no data is uploaded. It seems as if the PATCH requests to not make it to tusd. I would assume that you have some misconfigured proxy and would advise you to look at that. Also see https://github.com/tus/tusd/blob/main/docs/faq.md#can-i-run-tusd-behind-a-reverse-proxy

Hi Marus,
i’ve deleted the pre-create.

i have a simple post-finish script just to check things are working
image

when i upload a file i get


permission denied.

if i try and run that file from the directory i get permission denied
image

image

any ideas how to over come this?

thank you

Chris

Author moved the discussion to Permission denied running post-finish hook · Issue #921 · tus/tusd · GitHub.