Can I run a second instance of Joplin?

I just found this and one of the first things I came here to find out is if it’s possible to have multiple “channels”. Here the OP refers to them as “instances”. I’m not sure why we’d need a separate “instance” of the application in order to maintain different “channels” or “contexts” or whatever.

One of the things I detest about most social media that seems to have infused itself into far to many developers’ thinking is that our lives are monocultural – that everybody we deal with is all part of the same big happy family.

I’m sorry, but nothing could be further from the truth.

I keep my work and personal stuff separate, mainly because as a developer, if I don’t keep clear lines of demarcation, I could expose software (and just about anything) I create on my own to my employer, where they could claim it belongs to them.

But I also have multiple social circles and I’d like to be able to set up places to share files and information with people in these groups that’s not all part of the same “bucket” so to speak.

For example, I’m taking a couple of classes, and we need to have a place to post homework assignments, notes, anything we want to share amonst ourselves as one of 10 groups in (one of) the classes. The other class is larger and we’ve got things that need to be handed-out regularly to participants, and we need to provide a place for them to save things to.

FB sucks for this, and most platforms like Slack that are even half-way useful charge a monthly fee on a per-person basis, which nobody wants to pay for.

So it would really be nice to be able to set up multiple “channels” or whatever that have a separate storage account somewhere and can be shared among a group of unrelated people. (I don’t mind setting up an area on my Dropbox for the group in one of my classes to use, but I’m not about to give them the login info to allow them to connect!)

I realize this isn’t quite the vision this tool was built to fulfill, but it’s not all that far off. I have hosting, and I’d be happy to set up a NextCloud service if that’s what it takes, but I know some folks wouldn’t want to do that.

Anyway, being able to have multiple independent “channels” for my own personal needs would be great (without requiring multiple executable instances of the app).

It would also be great to have something similar where I can “invite” a limited number of people to “share” the same folder, and have multiple groups sharing separate folders, where I (admins) can also be members of each group to help manage things.

If I understand correctly these are 2 different things you @thetoolwiz are commenting on.

  1. discussing about instances, channels or contexts is basically targeting the same thing. While a separate/second instance would be decoupling the application from the content and allow for several profiles (another name for what you are considereing) with separate locations and login credentials being accessible at the same time each via one designated instance, the alternative might be to allow for profile switching within the same instance (similar to what Evernote supports). The latter then would only allow to work on notes belonging to the profile one is currently logged into.
    Both actually serves the same requirements: separating content e.g. work from personal.
    Personally I would prefer profile switching, as this would allow to have similar circumstances in all devices (desktop PC, smartphone…). Separate instances will work on a desktop PC but not with an Android or Apple smartphone…

  2. for sharing files and allowing users (e.g. pupils) to access the content of a storage space (for their particular class), a file sharing service like Nextcloud is actually the one you should be looking for. If configured right, users can share/upload stuff, but not delete/modify. A note taking service like Joplin is not necessarily the right choice to setup something like that - even though attaching files (images/PDFs and others) to a note is possible.
    A file sharing service like Nextcloud is easily set up, allows for perfectly separated data storage for work and private (or classes…). Joplin isn’t designed to compete with such.

The reason for asking for multiple instances is pretty easy to understand. It’s the easiest way to achieve multiple sync targets and to separate notes. What are the other options? Allow a sync target per notebook? Well, this would definitely be a nice feature, but also adds a lot of complexity to the code. Do you want to submit a PR?
I think there are other features more essential to a note taking app, but my feature request is rather easy to accomplish. Nobody says that other options aren’t possible in the future.

Sharing notes and notebooks has been discussed in several github issues and topics on this forum. Yes, it would be great. I was thinking about this for a very long time and I couldn’t find a feasible architecture to make this work. Yes, if one were only to use Nextcloud, no problem, but Joplin allows several sync targets, even your local filesystem, so I’m at a loss here. Maybe a sharing plugin per sync target could solve this, but this approach would be quite an endeavor.

As pointed out above, multiple instances are fine with Windows or macOS, but don’t work with iOS or Android. They’re basically different “profiles” or “channels” or something with a similar name. There are three or four ways to implement it that I can think of off-hand. I’ve done it in Windows by setting up separate INI files as well as separate DB tables. I guess it all depends how much decoupling you want between them.

As far as the file sharing, I don’t see what’s wrong with making it just for NextCloud initially, then add other options later.

I inquired with my hosting provider about installing NextCloud and was informed it’s included in the standard Softaculous app library that just about every cPanel hosting vendor provides, which makes it SUPER-EASY to install. (There are lots of servers / services that can only be installed if you have root access, making them nearly impossible to set up if you have a shared hosting plan.)

Also, it’s not like I’d need everything to get stuffed into one NextCloud instance. I’d be happy if I could set up separate NextCloud instances for each group I want to work with. (Assuming that’s possible.)

Furthermore, I don’t need full “colloaboration”, just the ability for people to easily post their own stuff and view things flagged for them to read. If it’s yours, you can update it; otherwise you get read-only access. I’m sure this would simplify a lot of the logic that can be imagined if full collaborative access were required. Also allow people to flag things as “public” or “private” so they could post their own notebooks there and not have to worry about others viewing them.

Alternatively you could enable a “lock for editing” option that lets people with write access update a document. But again, in my case, that’s probably not even a requirement.

Another use-case occurred to me recently. This may be a little closer to common messaging apps, but there’s some overlap.

I often want to have something of a shared message thread with someone, or a small group of people. Most of the content is static, but periodically it’s handy to go through and edit it.

Skype and other messaging apps just provide a huge scrolling list of notes that are organized strictly by time.

But a lot of interactions with people don’t occur that way. You discuss different topics at different times, going back and forth.

My sister has two kids, and since Christmas is approaching, she wants to talk about gifts. Specifically, gifts for one of her kids, in the domain of musical instruments. We’ve chatted about musical instruments in the past; the fact that Christmas is approaching is secondary.

We could get her partner engaged as well to discuss this.

But I discuss many different topics with my sister.

What I really hate about Skype and most messaging services is that it’s impossible to organize material by context. So if I want to find out something my sister suggested the last time we talked about musical instruments for her daughter, it’s way, WAY up in the timeline! But it may have been the most recent thing we discussed in this topic.

So just the ability to have multiple “threads” of comments under different topics, and share that specific collection of things among a group of people, seems rather unique. At least, I don’t know of anything that’s really designed for that.

It’s a “collaboration” tool in the sense that several people view and edit the content, but most of the editing is just appending to the end of a message thread. Sometimes, historical data might get changed as well.

All of these messaging apps are driving me nuts, because I tend to think about things categorically, not just linearly in time. I also find that for my own purposes, this isn’t nearly as much of an issue as it is when I’m coordinating with others.

So it’s a little different perspective on things.

Like others, I have some ‘regular’ notes and some confidential notes and I’d like the regular notes to sync between my work machine and my personal machines, but have my confidential notes only sync among my personal machines.

I have an additional use case for syncing – I’d like to be able to sync via WebDAV to my server, for sharing with my other personal machines and in ADDITION sync to the local file system. I use a Mac. I expect Spotlight, the Mac search tool to find anything on my Mac. Spotlight can’t see inside a SQL database. By syncing to the local file system, I create a set of Markdown files that Spotlight can see.

Unless I set up a separate sync tool like Syncthing or NextCloud, I currently must choose between Spotlight visibility and sharing with my other machines.

1 Like

Hi,
I am interested in implementing this solution.
But changing the behavior of --profile will break the retro compatibility.
What is your opinion on it?

Portable Windows version could be a solution - binary is always using profile in the current directory. But don’t know about other platforms and probably there is no way on Android.

I think this is a bigger conversation which @laurent has to lead. I have a few ideas, but it’s his code so he will have to decide on the architecture.
Also, I don’t think that we have to break backwards compatibility.

Nope, it's not. The only difference between portable and standard version is the location of the profile. That's all. We need to support multiple profiles within the same app and different profiles with parallel running apps. Completely different story. (Currently the portable and the standard app only support one profile in one running app.)

Does anyone know how the mechanism that currently makes sure only one instance is running actually works?

The app acquires a lock when it starts. If a second app is launched it can’t get the lock so it closes.

It’s quite straightforward and could indeed be disabled if we come up with a working multiple instances solution.

Yeah, but what does ‘acquires a lock’ mean?
I’ve implemented something similar once, a long time ago, but have no idea whether it’s compatible with Electron and all the platforms Joplin needs to run on.

That was just for counting instances (i.e. you can run 3 copies of an app, but not 4), but I guess the general mechanism could be modified.

If one can acquire a shared memory space (I have a vague recollection of using a memory-mapped file, I think?) that each process could read (and sometimes write) in a thread-safe manner.
Then at startup you could check that file to see whether the absolute path to the current profile directory is already in it; if yes, bring that one to the front and quit; if not, add it and continue running.

It’s the built-in Electron lock so I’m not sure how it’s implemented:

https://github.com/laurent22/joplin/blob/74c2bbc2f03fad089af2a0b1481f4d6876e2b5da/ElectronClient/app/ElectronAppWrapper.js#L193

It’s true we’d need a more sophisticated lock mechanism if we allow multiple instances. Something in memory would indeed be better so that if the app crashes it doesn’t keep the lock. I’m hoping there’s some nodejs package we could use for this, as getting locking right is often tricky.

Yep, but luckily even the new locking mechanism must not be very complicated. Files are out of the question. Let’s hope there’s a module we can use to create and access shared memory.

By the way, @tessus there’s a PR which I think is related to something you said about multiple profiles some times ago - https://github.com/laurent22/joplin/pull/1945 Is it still relevant today? Because for the implementation we’re discussing, this new flag is not needed.

It depends, I’ve already answered on github.

It all depends on the architecture that has to be designed first. I see a multiple profile, multiple instance solution, which means that I can have several instances of Joplin running at the same time, plus that I can switch profiles in one single Joplin instance. However this architecture will look like, I think it needs more fleshing out, before thinking about PRs in that area.
But this is just my vision. Maybe you only want to have one or the other. As I said, it all depends.

1 Like

@laurent22 any chance we can pick this up again?

P.S.: This just popped into my mind when I read another sharing request.

I still plan to implement this some day but don’t know when. Now that we know how to do it, maybe we could write a spec for it for a start, as that might help identify some small tasks that could be done first.

I just want to mention a current behavior that works in linux that might be something to consider when running 2 instances of the terminal application (i.e. cli).

Running 2 instances of the cli with the default profile doesn't work because the instances are sharing a /tmp directory. Upon sync the contents in /tmp changes and thus causes the files therein to be lost. This causes any external editor's file contents to be decoupled with the database representation (by id).

The work around that I've found is to create a second profile folder and create soft links for the keymap.json file and the resources directory within the second profile back to the first.

The second profile looks like this:

Joplin-2ndprofile
├── database.sqlite
├── keymap.json -> ../joplin/keymap.json
├── log-database.txt
├── log.txt
├── resources -> ../joplin/resources
└── tmp

Then running a second cli instance is straightforward: joplin --profile joplin-2ndprofile

I do not recommend linking the databases as that could be problematic in the future. Although it does work fine for now -again just don't do it without having clear development rules in place about database vs application instance behavior.

Also, FYI, soft linking the <profile>/resources directory from a joplin-desktop profile does seem to work but I haven't tested it very much.

In addition, I'd like to point out that while linking the <profile>/resources seems to work fine for cli and desktop apps. I'm weary of the practice without some dedication to this concept being a -feature- and not just a -hack-.

At any rate, by linking the <profile>/resources directories we save transfer back and fourth to your sync directory if you are using nextcloud, et. al.

[edit]: as a side note -it's probably obvious but do consider that editing the same note in multiple instances is not handled in the behavior outlined here. Therefore, editing the same file between multiple instances of Joplin at the same time is bound to create conflicts -hence, it's a bad idea :smiley:

1 Like