Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token expires after 24h and is not renewed #6

Open
vrachieru opened this issue Apr 9, 2018 · 7 comments
Open

Token expires after 24h and is not renewed #6

vrachieru opened this issue Apr 9, 2018 · 7 comments
Assignees

Comments

@vrachieru
Copy link
Member

The Skype token is valid for 24h after its creation and it is not properly renewed via SkypeConnection#refreshSkypeToken.
More info can be found in this and this issue.

As a temporary solution, the container can be restarted as follows:

*/5 * * * * /srv/ursar-bot/restart.sh
skype_username='username'
skype_password='password'
container_name='ursar'

is_running=$(docker exec ursar echo true 2>/dev/null || echo false)

echo "Is running: $is_running"

if [ "$is_running" = "true" ]
then
  start=$(docker inspect -f {{.State.StartedAt}} "$container_name")
  start_ts=$(date -d "$start" '+%s')
  now_ts=$(date '+%s')
  running_hours=$(( ( now_ts - start_ts ) / (60*60) ))
  echo "Running hours: $running_hours"
fi

if [ "$is_running" = "false" ]
then
  echo "Starting $container_name container"
  docker run --rm -t -e URSAR_SKYPE_USERNAME="$skype_username" -e URSAR_SKYPE_PASSWORD="$skype_password" --name "$container_name" academiadeursarie/ursar-bot
fi

if [ "$is_running" = "true" ] && [ "$running_hours" -ge "24" ]
then
  echo "Restarting $container_name container"
  docker stop "$container_name" && docker run --rm -t -e URSAR_SKYPE_USERNAME="$skype_username" -e URSAR_SKYPE_PASSWORD="$skype_password" --name "$container_name" academiadeursarie/ursar-bot
fi
@vrachieru
Copy link
Member Author

After further investigation it might be sufficient to provide a file in the SkypeEventLoop constructor where the token would be saved and then used to create a new token.
The current issue being that the token is not persisted anywhere.

Example:

# https://github.com/academia-de-ursarie/ursar-bot/blob/master/ursar/main.py#L14
super(UrsarBot, self).__init__(settings['SKYPE_USERNAME'], settings['SKYPE_PASSWORD'], 'token.txt)

@vrachieru vrachieru self-assigned this Apr 16, 2018
@fahadrokomari
Copy link

Is this issue fixed or any way around with this?

@vrachieru
Copy link
Member Author

Read the explanation above...
It's not fixed, as you can see, the issue is still open.

@fahadrokomari
Copy link

@vrachieru Ok... Is there any way around this ?

@vrachieru
Copy link
Member Author

@fahadrokomari It's explained above how you can restart the container with a cron to work around this issue..
The script is literally the first thing in this issue.
WTF?!

@fahadrokomari
Copy link

WTF= Wow that's fun.
Yes, I have got this. I do restart the script. But it seems not very legit. Thank you for your help though. I was doing this for a while but thought there is some other way around.

Restarting a container is like a "Microsofts" solution. By the way, have a nice day.

@vrachieru
Copy link
Member Author

@fahadrokomari Well that's what a workaround is, it's not pretty, I agree 😄 .
If you do find a better way PRs are welcome.
As you can see we haven't touched this project in a while so fixing this isn't a priority.
You have a nice day too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants