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

Frontpage Upgrade Issue #44

Open
glenn-sorrentino opened this issue Apr 23, 2024 · 0 comments
Open

Frontpage Upgrade Issue #44

glenn-sorrentino opened this issue Apr 23, 2024 · 0 comments
Assignees

Comments

@glenn-sorrentino
Copy link
Member

Frontpage Upgrade

Steps

Step 1: Update and Sync

  1. Update repo with new code tested locally

    • Added Media section
      • New tables - logos, citations
      • Update migrations/versions file with info from live site + schema from new migrations
  2. Rsync entire working server to dev server

    • rsync -aAXvP --delete -e "ssh -i ~/.ssh/frontpage-dev" --exclude={"/dev/*","/.ssh/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / root@64.23.217.243:/

Step 2: Prep Dev Server

  1. Clean nginx conf file
    • rm /etc/nginx/sites-available/ddosecrets.news.nginx && nano /etc/nginx/sites-available/ddosecrets.news.nginx
server {
        root /var/www/html/frontpage;
        server_name test.ddosecrets.news;
        location / {
            proxy_pass http://127.0.0.1:5000/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_connect_timeout 300s;
            proxy_send_timeout 300s;
            proxy_read_timeout 300s;
        }
                
        add_header Strict-Transport-Security "max-age=63072000; includeSubdomains";
        add_header X-Frame-Options DENY;
        add_header X-Content-Type-Options nosniff;
        add_header Content-Security-Policy "default-src 'self'; script-src 'self'; img-src 'self' data: https:; style-src 'self'; frame-ancestors 'none';";
        add_header Permissions-Policy "geolocation=(), midi=(), notifications=(), push=(), sync-xhr=(), microphone=(), camera=(), magnetometer=(), gyroscope=(), speaker=(), vibrate=(), fullscreen=(), payment=(), interest-cohort=()";
        add_header Referrer-Policy "no-referrer";
        add_header X-XSS-Protection "1; mode=block";
}
server {
        listen 80;
        server_name test.ddosecrets.news; # YOUR URLS
        return 301 https://test.ddosecrets.news$request_uri/;
}
server {
    if ($host = test.ddosecrets.news) {
        return 301 https://$host$request_uri/;
    } # managed by Certbot

server_name test.ddosecrets.news;
    listen 80;
    return 404; # managed by Certbot
}
  1. certbot --nginx -d test.ddosecrets.news
  2. systemctl enable frontpage.service && systemctl start frontpage.service

Step 3: Upgrade App

  1. git stash save "Saved local changes before pulling new changes"
  2. git pull && chmod +x install.sh && ./install.sh
  3. Click on "About Us" (old team page)
  4. Internal Service Error
(venv) root@frontpage-dev:/var/www/html/frontpage# /var/www/html/frontpage/venv/bin/gunicorn -w 4 -b 127.0.0.1:5000 frontpage:app
[2024-04-23 05:51:12 +0000] [3522] [INFO] Starting gunicorn 21.2.0
[2024-04-23 05:51:12 +0000] [3522] [INFO] Listening at: http://127.0.0.1:5000/ (3522)
[2024-04-23 05:51:12 +0000] [3522] [INFO] Using worker: sync
[2024-04-23 05:51:12 +0000] [3523] [INFO] Booting worker with pid: 3523
[2024-04-23 05:51:12 +0000] [3524] [INFO] Booting worker with pid: 3524
[2024-04-23 05:51:12 +0000] [3525] [INFO] Booting worker with pid: 3525
[2024-04-23 05:51:13 +0000] [3526] [INFO] Booting worker with pid: 3526
[2024-04-23 05:51:24,454] ERROR in app: Exception on /about [GET]
Traceback (most recent call last):
  File "/var/www/html/frontpage/venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1971, in _exec_single_context
    self.dialect.do_execute(
  File "/var/www/html/frontpage/venv/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 919, in do_execute
    cursor.execute(statement, parameters)
sqlite3.OperationalError: no such table: logos

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/var/www/html/frontpage/venv/lib/python3.11/site-packages/flask/app.py", line 1473, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/html/frontpage/venv/lib/python3.11/site-packages/flask/app.py", line 882, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/html/frontpage/venv/lib/python3.11/site-packages/flask/app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/html/frontpage/venv/lib/python3.11/site-packages/flask/app.py", line 865, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/html/frontpage/frontpage/routes.py", line 866, in about
    logos = Logo.query.all()
            ^^^^^^^^^^^^^^^^
  File "/var/www/html/frontpage/venv/lib/python3.11/site-packages/sqlalchemy/orm/query.py", line 2673, in all
    return self._iter().all()  # type: ignore
           ^^^^^^^^^^^^
  File "/var/www/html/frontpage/venv/lib/python3.11/site-packages/sqlalchemy/orm/query.py", line 2827, in _iter
    result: Union[ScalarResult[_T], Result[_T]] = self.session.execute(
                                                  ^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/html/frontpage/venv/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 2306, in execute
    return self._execute_internal(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/html/frontpage/venv/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 2191, in _execute_internal
    result: Result[Any] = compile_state_cls.orm_execute_statement(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/html/frontpage/venv/lib/python3.11/site-packages/sqlalchemy/orm/context.py", line 293, in orm_execute_statement
    result = conn.execute(
             ^^^^^^^^^^^^^
  File "/var/www/html/frontpage/venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1422, in execute
    return meth(
           ^^^^^
  File "/var/www/html/frontpage/venv/lib/python3.11/site-packages/sqlalchemy/sql/elements.py", line 514, in _execute_on_connection
    return connection._execute_clauseelement(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/html/frontpage/venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1644, in _execute_clauseelement
    ret = self._execute_context(
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/html/frontpage/venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1850, in _execute_context
    return self._exec_single_context(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/html/frontpage/venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1990, in _exec_single_context
    self._handle_dbapi_exception(
  File "/var/www/html/frontpage/venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2357, in _handle_dbapi_exception
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
  File "/var/www/html/frontpage/venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1971, in _exec_single_context
    self.dialect.do_execute(
  File "/var/www/html/frontpage/venv/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 919, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: logos
[SQL: SELECT logos.id AS logos_id, logos.file AS logos_file, logos.description AS logos_description 
FROM logos]
(Background on this error at: https://sqlalche.me/e/20/e3q8)
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