Page 2 of 2

Re: Data logs 2 records per minute?

Posted: Thu 08 Dec 2022 11:33 am
by broadstairs
mcrossley wrote: Thu 08 Dec 2022 10:36 am
SamiS wrote: Wed 07 Dec 2022 8:15 pm @Mark: How foolproof is the detection if first instance is run as service (maybe under root permissions) and second instance from commandline as different user? And if I am correct, this would actually cause processes to keep their own differently named logfiles in MXdiags folder?
It creates a system mutex based on a static GUID allocated to CMX. It seems to be a pretty robust mechanism, killing a process can leave the system mutex open and you will get a warning on restarting (MX can detect the difference between an open and an abandoned mutex). How well it works with processes in different security contexts I'm not so sure, but as it is a system wide lock I'd expect it to work.
Well sorry to report but under Mono/Linux I CAN start two copies of CMX just fine no errors at all, you solution does not work. I also just checked again and the stop second instance IS set.

That does NOT mean I did start two but it is possible that forcing off the console window could leave it running in the background but even that is a remote possibility and to my mind should not happen. If I ever have to do that I'll check first to make sure mono has stopped.

Stuart

Re: Data logs 2 records per minute?

Posted: Thu 08 Dec 2022 11:43 am
by mcrossley
Bugger - so it doesn't. I wonder if this is a bug in newer versions of Mono, they have had bugs with mutex's before :(
Starts digging...

Re: Data logs 2 records per minute?

Posted: Thu 08 Dec 2022 11:52 am
by mcrossley
It still works on Windows, so it is looking like a mono problem...

Re: Data logs 2 records per minute?

Posted: Thu 08 Dec 2022 11:55 am
by broadstairs

Re: Data logs 2 records per minute?

Posted: Thu 08 Dec 2022 12:40 pm
by freddie
@mcrossley usage of systemd on Linux provides an immediate workaround. Best to run as a service rather than from the command line.

Re: Data logs 2 records per minute?

Posted: Thu 08 Dec 2022 1:55 pm
by mcrossley
broadstairs wrote: Thu 08 Dec 2022 11:55 am Mark I just found

https://stackoverflow.com/questions/212 ... x#21750422
Yep, I found that too, but it is out of date. They added support for mutexes later.
freddie wrote: Thu 08 Dec 2022 12:40 pm @mcrossley usage of systemd on Linux provides an immediate workaround. Best to run as a service rather than from the command line.
Yep, running as a service and starting another service isn't an issue, it creates a lock file containing the process id.

Maybe I need to look at something similar for MX, the file needs to be globally readable of course.

Re: Data logs 2 records per minute?

Posted: Thu 08 Dec 2022 6:07 pm
by broadstairs
Mark if you come up with something which needs testing my CMX is not live so it's easy for me to play around trying anything.

Stuart

Re: Data logs 2 records per minute?

Posted: Thu 08 Dec 2022 7:50 pm
by freddie
mcrossley wrote: Thu 08 Dec 2022 1:55 pm Yep, running as a service and starting another service isn't an issue, it creates a lock file containing the process id.
Yep I know that - I meant recommend running as a service. No disadvantage and it is only a one-time extra step.