On our Ubuntu Xenial(16.04) station I host a bot written in Python that connects to our IRC server that's set to launch in
Our bot was connecting twice though the script is set to only run one instance and if its username is taken it must close the current connection and reconnect under the next username.
ps aux | grep bot_name.py$ to determine the issue was not at the script level, but for some reason two instances of the script were being run when Ubuntu connected to the internet.
I've created a workaround on the script level that checks how many instances of the script are running locally and if it's any number besides one, it will close the script.
What would be some reasons
if-up.d/might launch two instances of a single script stored in its directory?
The script in
if-up.d/ is a sh script that wraps the call to python so it waits past the timeout period for irc then connects:
sleep 269 sh -c "python /dir/to/bot.py >> /dir/to/log" & disown
So far, I've seen the issue mirrored here in a different context where someone used a python script to send emails and the recipients received multiple emails due to multiple instances of their script launching.
I was also able to find this question for 16.04 on Server Fault where someone experienced a similar issue and the answer listed suggested it might be running twice because there's one instance launched for IPv4 and IPv6, though I'm not sure if this is actually the root cause or how to specify you'd only want to use IPv4 and forego the IPv6 call if that was the case.
Between our 3 cases, Ubuntu 16.04 seems to be the common thread which makes me wonder if this is a bug.