Fork me on GitHub
#joker
<
2020-07-04
>
gleisonsilva16:07:27

Some tip to avoid running a joker process (without relying in ps if using Linux) to check if an instance of Joker is running? I can't let the user run this script in parallel...

jcburley03:07:23

As Joker can be running a script, REPL, or a lint checker, it’s probably best to not gate access to a resource (manipulated by a particular Joker script) on whether any other Joker instance is running. E.g. you wouldn’t want to prevent a script running just because its interpreter (whether Joker, bash, or python) happens to be running somewhere else on the system.

gleisonsilva16:07:14

I'm search for some kind of simple 'locking' or 'exclusive access' to some resource to avoid collision...

jcburley03:07:18

IMO this is best done by wrapping, with a locking scheme, access to the resource itself, rather than to the script that manipulates it, as tempting as that might be for a quick one-off need.

👍 3
gleisonsilva16:07:12

Or even some way to get the PID of the process that the script is running in

jcburley03:07:59

This works in my gostd fork (though that’s definitely not “stable” at this time):

user=> (go.std.os/Getpid)
9220
user=> (go.std.os/Getppid)
564
user=>
Functions like this could probably be easily ported to joker.os in the official version.

jcburley03:07:59

This works in my gostd fork (though that’s definitely not “stable” at this time):

user=> (go.std.os/Getpid)
9220
user=> (go.std.os/Getppid)
564
user=>
Functions like this could probably be easily ported to joker.os in the official version.

jcburley03:07:18

IMO this is best done by wrapping, with a locking scheme, access to the resource itself, rather than to the script that manipulates it, as tempting as that might be for a quick one-off need.

👍 3
jcburley03:07:23

As Joker can be running a script, REPL, or a lint checker, it’s probably best to not gate access to a resource (manipulated by a particular Joker script) on whether any other Joker instance is running. E.g. you wouldn’t want to prevent a script running just because its interpreter (whether Joker, bash, or python) happens to be running somewhere else on the system.