robertoszek / pleroma-bot

Bot for mirroring one or multiple Twitter accounts in Pleroma/Mastodon/Misskey.
https://robertoszek.github.io/pleroma-bot
MIT License
103 stars 19 forks source link

add argument for lockfile location? #98

Closed us3r1d closed 1 year ago

us3r1d commented 2 years ago

The bot seems to always drop its lockfile as /tmp/pleroma-bot, which means that only one copy can be running system-wide.

This is ... interfering with my usage. :-)

Can you add a --lockfile argument to override the default lock location?

(I'm assuming the lock is to prevent contention over the users/ and tweets/ directories, which seem to be in the current working directory, so maybe adding --basedir and having that control the locations of both those directories and the lockfile by putting them inside basedir/ would make more sense?)

Basically, I just want to run multiple copies on the same VM; I'm guessing that hasn't been an issue yet for other users, so I wouldn't ask for this to be a priority. :-)

robertoszek commented 2 years ago

Hi! You're very much on the money, the main idea behind the locker was to avoid collisions if an user launched the bot as a daemon, forgot about it and tried spawning a new bot instance.

But now that you bring it up, I think it would make more sense to by default do as you mentioned and drop the lockfile next to the config file (the basedir basically) instead of doing it always on /tmp.

And adding an argument to specify its path wouldn't hurt either, at that point you must know what you're doing if you're changing it to something else.

robertoszek commented 2 years ago

I've committed the changes to the develop branch, this should be enough: 0acf8ed2bcd36be52cf2e59d584c2a5abca060df

Adds the argument and by default it will put the lockfile next to your config file (the one in the current working directory or the one specified with --config):

  -L LOCKFILE, --lockfile LOCKFILE
            path of lock file (pleroma-bot.lock) to prevent
            collisions with multiple bot instances. By default it
            will be placed next to your config file.

If you need it right now, you can install the rc release containing the change like so: pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple pleroma-bot==1.1.1rc24

nemobis commented 2 years ago

I previously worked around this by setting the TMPDIR environment variable, FWIW.