Multiple instances of soffice.bin at the same time

we are converting office documents to pdf’s using Libre office, Instead of sequential processing we need to do it parallelly hence we need to run multiple instances of soffice.bin, I understand that we need to use seperate user profiles to do that. So I decided to create a new user profile and the converting the document to pdf something like below command

soffice.exe --headless -env:UserInstallation=file:///c:/temp/Userprofile --convert-to pdf --outdir "C:/temp/PDFs" "C:/temp/input/test.docx" 

Every time I am creating a new userprofile in different location so once my job is done I wanted to delete the created user profile.
So Is there any way to delete user profiles using soffice commands instead of general delete command ?

on linux I would just do:

soffice.exe --headless -env:UserInstallation=file:///c:/temp/Userprofile --convert-to pdf --outdir "C:/temp/PDFs" "C:/temp/input/test.docx"  && rm -r c:/temp/Userprofile

sorry dont know the equivalent command on Windows

1 Like

May I ask what the qualitative difference is?

No. Just delete using a shell command in the same script used to run soffice. And make sure you read and comprehend the command line documentation, which, in case of Windows, explicitly advises against use of soffice.exe in scripts (it suggests using soffice.com). Or make sure that your script waits for the application to finish (does not happen automatically with soffice.exe).

Or maybe think how to not delete the profile, but reuse it instead. Creation of a profile is an expensive process; it may slow down your processing considerably. If you invent a way to have several profiles (say, numbered according to your CPU core count), and issue respective number of --convert-to calls with multiple files, you would make it much more efficient.

What exactly is expensive about creating a small almost »empty« directory tree?
It seems irrelevant compared to maybe converting hundreds of ~50Mb-docx’s to pdf?
ps. of course it should not be done for each an every single Document again!

What exactly makes you believe that profile creation is just a creation of “almost empty” directory tree? What exactly prevents you from believing that LibreOffice might do something complex here, including scanning installed extensions, caching stuff, checking graphic card compatibility, and so on?

And IIUC, what I wrote was exactly

Sorry I just realized that point later, at first I did not even consider that the OP actually executes the command with individual documents.

Here I don’t quite follow you, doesn’t this have to happen every time soffice starts? ( and extensions-installed-by-users should hardly be exist at the moment of creating-user-config)

No, it doesn’t - it happens when creating a new profile, or when last started version is not the same as current, or in some other specific cases like installing a new extension. And scanning extensions is not limited to user’s - the scan may disable e.g. a shared extension that is not compatible with current version (the disabled status will be saved in user profile).

Additionally, such a profile creation causes soffice.bin restart.

What do you think, instead of creating new profile everytime, can I copy the just existing profile to a new location ? Note that, the profile maybe in use by some other process

Copying a profile could be an option, too (an inferior to having several ready profiles, but still better than creating one each time)

Just to confirm,
If I am using multiple user profiles, Do I need to run this command (soffice.com -env:UserInstallation=file:///c:/my-test-profile) to inform soffice that use this particulat user profile before doing --convert-to pdf ?

I just wanted to set the userprofile path, but running soffice.exe and waiting to finish it in my script or running soffice.com both not exiting just after set the user profile path, these are exiting only after conver-to call (if --headless) or closing the opened Libre office GUI (if no --headless).

I just wanted to set the user profle path for all subsequent soffice calls and don’t want to keep soffice run in the background. I will run soffice again later if I want to do conver-to calls , Is this possible ?

@mikekaganski Any idea on this ?

I am unsure if I understand your issue: when you start soffice with a path to profile URL that doesn’t exist yet, it gets created; when you call it again with the same URL later, it gets reused (unless you deleted it in the middle).

@mikekaganski
I run the following command,
C:\Program Files\LibreOffice\program\soffice.com" --headless -env:UserInstallation=file:///c:/Lo/Userprofile --convert-to pdf --outdir “C:\Lo\PDFs” “C:\Lo\1.txt”
the user profile gets created and in task manager soffice.bin and soffice.exe exited after converting to pdf, this is fine.

When I run the below command just to create a user profile but not any file conversion
C:\Program Files\LibreOffice\program\soffice.com" --headless -env:UserInstallation=file:///c:/Lo/Userprofile

This is creating user profile but soffice is not exiting, soffice.bin and soffice.exe are still running in the background (can be seen in task manager)

I just wanted to create a profile in the initialization process, and keep it ready for next file conversions.
How can I run soffice.com to just create a profile and exit smoothly without waiting ?

In the command line documentation, there are two “Developer arguments”, that could help you: --terminate_after_init and --eventtesting. Both are created to terminate after some initial routine. Of them, --eventtesting looked more suitable, because it is intended to proceed further before termination: it should only exit after loading documents, so the profile creation would be “more complete”. However, in my testing on an Ubuntu system (I’m at the conference right now, away from my home Windows system), the --eventtesting seems broken: trying to use it from the command line emits an error. So - you could use the other one:

soffice --terminate_after_init -env:UserInstallation=file:///c:/Lo/Userprofile

@mikekaganski I really appreciate your support (though you are away today), I tried it on windows as you mentioned --eventtesting is broken on windows too. Anyway I don’t want to load the documents just only create the profile first, so as per command line documentation --terminate_after_init is suitable for my siutation and I tried this and working fine.
Only difference I can see that is, when I manually open the libre office the user folder created on temp directory is around 346KB but user folder created with --terminate_after_init is only 166KB
Is this fine ? or am I missing something important here ?

This is exactly what I was talking about. After loading a document could be just creating a new document - which means, that not only LibreOffice starts, but also the respective component (Writer) also loads, and so creates respective module-specific cinfig initiatialization.

But still I don’t think that you should be concerned with this complete pre-initialization. The extra ms was not a problem for your initial “let’s drop the profile every time”; if you simply don’t drop it, and reuse, it would be great. Indeed, your other idea of copying a template profile, your question makes sense; this is what makes you want a command to create such a template profile, and also to have it as complete as possible. But IMO, you would spend time wiser in developing a method to run N processes, and sending incoming documents to them in a circular fashion.

My ideas is to create a profile initially and keep it (without loading a document) later when we receive multiple requests to convert the document to pdf, just copying the initial profile to different directory and use that for document convertion (copying profile is just taking 20 milli seconds so I decided to choose this approach).
But now, I think instead of creating profile initially without loading a document I think, I need to create it for the first time when document converts later on re-use that by a copy since only, after document loading creates full&proper profile.
I understood now what need’s to be done in my case. Thank you again !