Schema bot

Bot for fetching the schema.org external link full hierarchy to generate the Hierarchy.pickle file

The Bot class will check for the existence of the pickle file and for the version

  • If the file doesn’t exist, it will be generated by the Bot
  • If the file is outdated, it will be updated by the Bot

After updating the Hierarchy.pickle file, a new static index.html will be generated

The Bot should be called via a cron job every 24 hours

  • The Application Server Controller (or Controllers) will be restarted if necessary

Starting the bot

computer:~$ ./schema_bot.py

or

computer:~$ python3 schema_bot.py

Restarting the server(s)

To restart the server(s), the restart(port) function should be called for each port as shown below If the ports are consecutive, a for-loop can be used, of course.

This code is, naturally, inside the schema_bot.py file

if __name__ == "__main__":
    from os import chdir

    print('Schema Bot - main')

    # Change the base dir to where this __file__ is located
    # Same location as the Hierarchy.pickle file
    FILE_NAME = 'schema_bot.py'
    if __file__ != FILE_NAME:
        BASE_DIR = __file__[:__file__.index(FILE_NAME)]
        chdir(BASE_DIR)

    # Start the Bot
    # Check if file exists
    # Check if version is correct
    b = Bot()

    # Everything happens while the bot is alive
    while b.is_alive():
        pass

    # Restart the server(s) if the pickle file has been updated
    if b.updated:
        restart(8000)   # Restart server at port 8000
        restart(8001)   # Etc
    print('Schema Bot - main finished')