Seafile Pro as non root user very slow startup (lots of chowns being run)

I just started to use Seafile, running Seafile Pro 11.0.6. I have a library that’s now about ~400 GB, mostly photos. Whenever I restart Seafile (running in docker compose), it takes like 5 minutes to start.

I’ve debugged a bit and found out that it’s because I’m running the seafile container as NON_ROOT. Running as root, it starts in seconds.

I see some entries that change the ownership of all files in the shared directory.

chown -R seafile:seafile /shared/

This command looks like it’s run three times(!?) in the scripts folder:

./enterpoint.sh:31:    chown -R seafile:seafile /opt/seafile/ 
./enterpoint.sh:32:    chown -R seafile:seafile /shared/
./start.py:76:            call('chown -R seafile:seafile /shared/seafile/')
./cluster_start.py:48:            call('chown -R seafile:seafile /shared/seafile/')

Is it really necessary to run this, on every startup? Three times? Shouldn’t this be a setting being set once, and then you stick with it? (Trying to change from non-root to root does not seem to be supported.)

This has been fixed in update: chown share_seafile by an enviroment var by wacmkxiaoyi · Pull Request #387 · haiwen/seafile-docker · GitHub

This was not fixed, i’m trying to upgrade to 13 (docker ce) and the healthcheck timeout makes seafile fail to start for my non-root setup where i can see chown in top doing something.

It looks like the linked pull request makes an override environment variable. By default he
chown still happens, but you can disable it by setting NON_ROOT_CHOWN_FILES to false in the environment.

It seems like I am facing the same issue. I am running as NON_ROOT, all files already have the correct rights. Still for each start of the docker container it takes roughly half an hour to chown the files.

I am using Seafile CE 12, have not upgraded to 13 yet.

@tomservo I couldn´t find any reference to the setting NON_ROOT_CHOWN_FILES you mentioned.

I found that by following the link @daniel.pan posted to pull request #387. On that page there are some links to diffs showing what changes to the code are part of the pull request. One of them is this one: update: chown share_seafile by an enviroment var by wacmkxiaoyi · Pull Request #387 · haiwen/seafile-docker · GitHub

There you can see that call('chown -R seafile:seafile /shared/seafile/') has been replaced with:

            non_root_chown_files = os.getenv('NON_ROOT_CHOWN_FILES', default='') == 'true'
            if non_root_chown_files:
                call('chown -R seafile:seafile /shared/seafile/')

I’m not a python expert, but I believe that is saying that if the environment variable NON_ROOT_CHOWN_FILES exists, and is set to false, the chown will be skipped. Please tell me if I have read that incorrectly, since I plan to set that env variable on my own setup soon.

You are right, I missed that because I was just looking at the master branch.

The environment variable was removed again quite soon and the handling was changed if you have a look at the history. Seems like I cannot paste links yet.