2
  1. So I've created https://phuks.mydomain.com and after working around with it, I run the npm run build && killall -HUP gunicorn and everything is built OK. However, the site still points to a sample index.html that I initially created when creating the subdomain. Even after deleting the index.html file, it still points to that file. What do I need to do here? I've tried redis-cli FLUSHALL but that also doesn't work. Are there any cache files that I need to delete? Where?

  2. OR do I need to make any changes to files like config.py? Besides this, are there any other files I need to look at? Here's how my config.py file looks like.

""" This is the config file. Pretty obvious, right? """

import os

\#Site title

LEMA = "*MySite*: Share and discuss"

\#Copyright notice, used in the footer

COPY = "2019 *MySite*. All Rights Reserved."

\#XXX: LEGACY - FIX EVERYTHING AND REMOVE THIS BLOCK

DB_HOST = 'localhost'

DB_USER = 'root'

DB_PASSWD = 'somepassword'

DB_NAME = 'throat2'

\#peewee

DATABASE_URL = 'mysql://{0}:{1}@localhost/{2}'.format(DB_USER, DB_PASSWD, DB_NAME)

\#Method used to memoize stuff.

CACHE_TYPE = 'simple'

\#Only used if CACHE_TYPE is 'redis'.

CACHE_REDIS_HOST = '127.0.0.1'

CACHE_REDIS_PORT = 6379

CACHE_REDIS_DB = 5

\#The Redis that we use for SocketIO. This must be the same for all instances

SOCKETIO_REDIS_URL = 'redis://127.0.0.1:6379/1'

\#Secret key used to encrypt session cookies. CHANGE THIS

SECRET_KEY = '\x80\x9b\x0ce\xe2\xb8\x04\xb9\x99\xa3\x13\xf7+K\xf6\xdf"\xbf\xfb\x82\x96\xc9\xda\x8e'

\#wtforms settings. Set to False to disable CSRF

WTF_CSRF_ENABLED = True

WTF_CSRF_SECRET_KEY = SECRET_KEY

\#Sengrid API key, only used to send password recovery emails

SENDGRID_API_KEY = ""

SENDGRID_DEFAULT_FROM = "[email protected]"

\#Recaptcha credentials

RECAPTCHA_PUBLIC_KEY = "6Lf4xHIUAAAAAFCqMveyHfpE5tccaWrDjv9tKIQc"

RECAPTCHA_PRIVATE_KEY = "6Lf4xHIUAAAAACqZYmEGxIdhlPg_OCVkCTK52LkM"

\#This is the path thumbnails will be stored on

THUMBNAILS = "./thumbs"

\#This is the domain where the thumbnails are hosted on. Can be an absolute path too.

THUMBNAIL_HOST = "https://dev.*MySite*.co/t/"

\#THUMBNAIL_HOST = "/static/thumbnails"

\#Same as above but for file storage (Used for user and sub file uploads)

STORAGE = "./stor"

STORAGE_HOST = "https://dev.*MySite*.co/i/"

\#SID of changelog sub (used to display last changelog entry on the sidebar)

CHANGELOG_SUB = '9a79b49e-7bd3-4535-8ad6-ba11fc1d0ef5'

\#Only for debugging and testing:

DEBUG = False

TESTING = False \#This makes all the captchas valid

\#Address of the socketio server. If it's left empty socketio will attempt to connect

\#to /socket.io.

WEBSOCKET_SERVER = ''

\#Max content-length accepted by the server

MAX_CONTENT_LENGTH = (1024 * 1024) * 10 \#10MB limit

\#Prefix for subs. Must always start with /.

SUB_PREFIX = "/s"

1. So I've created https://phuks.mydomain.com and after working around with it, I run the `npm run build && killall -HUP gunicorn` and [everything is built OK](https://i.imgur.com/mHPBi7R.png). However, the site still points to a sample index.html that I initially created when creating the subdomain. Even after deleting the index.html file, it still points to that file. What do I need to do here? I've tried `redis-cli FLUSHALL` but that also doesn't work. Are there any cache files that I need to delete? Where? 2. OR do I need to make any changes to files like config.py? Besides this, are there any other files I need to look at? Here's how my config.py file looks like. === `""" This is the config file. Pretty obvious, right? """` `import os` `\#Site title` `LEMA = "*MySite*: Share and discuss"` `\#Copyright notice, used in the footer` `COPY = "2019 *MySite*. All Rights Reserved."` `\#XXX: LEGACY - FIX EVERYTHING AND REMOVE THIS BLOCK` `DB_HOST = 'localhost'` `DB_USER = 'root'` `DB_PASSWD = 'somepassword'` `DB_NAME = 'throat2'` `\#peewee` `DATABASE_URL = 'mysql://{0}:{1}@localhost/{2}'.format(DB_USER, DB_PASSWD, DB_NAME)` `\#Method used to memoize stuff.` `CACHE_TYPE = 'simple'` `\#Only used if CACHE_TYPE is 'redis'.` `CACHE_REDIS_HOST = '127.0.0.1'` `CACHE_REDIS_PORT = 6379` `CACHE_REDIS_DB = 5` `\#The Redis that we use for SocketIO. This must be the same for all instances` `SOCKETIO_REDIS_URL = 'redis://127.0.0.1:6379/1'` `\#Secret key used to encrypt session cookies. CHANGE THIS` `SECRET_KEY = '\x80\x9b\x0ce\xe2\xb8\x04\xb9\x99\xa3\x13\xf7+K\xf6\xdf"\xbf\xfb\x82\x96\xc9\xda\x8e'` `\#wtforms settings. Set to False to disable CSRF` `WTF_CSRF_ENABLED = True` `WTF_CSRF_SECRET_KEY = SECRET_KEY` `\#Sengrid API key, only used to send password recovery emails` `SENDGRID_API_KEY = ""` `SENDGRID_DEFAULT_FROM = "[email protected]"` `\#Recaptcha credentials` `RECAPTCHA_PUBLIC_KEY = "6Lf4xHIUAAAAAFCqMveyHfpE5tccaWrDjv9tKIQc"` `RECAPTCHA_PRIVATE_KEY = "6Lf4xHIUAAAAACqZYmEGxIdhlPg_OCVkCTK52LkM"` `\#This is the path thumbnails will be stored on` `THUMBNAILS = "./thumbs"` `\#This is the domain where the thumbnails are hosted on. Can be an absolute path too.` `THUMBNAIL_HOST = "https://dev.*MySite*.co/t/"` `\#THUMBNAIL_HOST = "/static/thumbnails"` `\#Same as above but for file storage (Used for user and sub file uploads)` `STORAGE = "./stor"` `STORAGE_HOST = "https://dev.*MySite*.co/i/"` `\#SID of changelog sub (used to display last changelog entry on the sidebar)` `CHANGELOG_SUB = '9a79b49e-7bd3-4535-8ad6-ba11fc1d0ef5'` `\#Only for debugging and testing:` `DEBUG = False` `TESTING = False \#This makes all the captchas valid` `\#Address of the socketio server. If it's left empty socketio will attempt to connect` `\#to /socket.io.` `WEBSOCKET_SERVER = ''` `\#Max content-length accepted by the server` `MAX_CONTENT_LENGTH = (1024 * 1024) * 10 \#10MB limit` `\#Prefix for subs. Must always start with /.` `SUB_PREFIX = "/s"`

15 comments

[–] curious [OP] 0 points (+0|-0) Edited

Thank you again @E-werd

Make sure your gunicorn configuration is indeed using the correct directory and you're not actually running the main site twice.

I use the following commands one after the other. Anything else I need to do?

PS: :/var/www/dev.mysite.co/public_html# is where all the files of my subdomain are.

cd /var/www/dev.mysite.co/public_html

/var/www/dev.mysite.co/public_html#  npm run build && killall -HUP gunicorn

with the results being..(truncated on purpose)


[email protected] build /var/www/dev.mysite.co/public_html
NODE_ENV=production webpack -p --optimize-minimize --progress

....

Child extract-text-webpack-plugin:

       [0] ./~/css-loader/lib/css-base.js 1.46 kB {0} [built]

       [1] ./~/css-loader!./~/tingle.js/dist/tingle.css 3.75 kB {0} [built]

Child extract-text-webpack-plugin:

       [0] ./~/css-loader/lib/css-base.js 1.46 kB {0} [built]

       [1] ./~/css-loader!./~/flatpickr/dist/themes/dark.css 14.9 kB {0} [built]

Child extract-text-webpack-plugin:

       [0] ./~/css-loader/lib/css-base.js 1.46 kB {0} [built]

       [1] ./~/css-loader!./app/static/css/main.css 23.3 kB {0} [built]

Child extract-text-webpack-plugin:

       [0] ./~/css-loader/lib/css-base.js 1.46 kB {0} [built]

       [1] ./~/css-loader!./app/static/css/dark.css 6.65 kB {0} [built]

root@ubuntu-s-1vcpu-1gb-fra1-01:/var/www/dev.mysite.co/public_html# Connection reset by XXX.XXX.XXX.0 port 22

[–] E-werd 0 points (+0|-0)

First of all, you don't need to run npm run build unless you've changed the css. It doesn't hurt anything, but it takes time that you don't need to spend.

Second, you're not showing me what I'm referring to. There's got to be a command in some sort of script that calls throat's code through gunicorn. For example:

cd /var/www/mysite.co/public_html
gunicorn -w 2 wsgi:app --error-logfile error.log --worker-class eventlet --bind 127.0.0.1:5000

Notice how this one is changing the directory to mysite.co? If you copied the script from the primary site, it may still be going to mysite.co instead of dev.mysite.co. Maybe you made an init or systemd script for this, I don't know. Review how your instance works and look for this sort of issue.

[–] curious [OP] 0 points (+0|-0) Edited

First of all, you don't need to run npm run build unless you've changed the css.

  1. TIL

Second, you're not showing me what I'm referring to. There's got to be a command in some sort of script that calls throat's code through gunicorn. For example:

cd /var/www/mysite.co/public_html
gunicorn -w 2 wsgi:app --error-logfile error.log --worker-class eventlet --bind 127.0.0.1:5000
  1. Yes! There is this start.sh script in /var/www/dev.mysite.co/public_html. Replace "/home/app with /var/www/dev.mysite.co/public_html ?

The contents are:


#!/bin/bash

export HOME="/home/app"
export USER="app"
export PATH="/home/app/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
cd /home/app/throat
gunicorn -w 1 wsgi:app --error-logfile error.log --worker-class eventlet --bind 127.0.0.1:8001

[–] E-werd 1 points (+1|-0) Edited
  1. Yes! There is this start.sh script in /var/www/dev.mysite.co/public_html. Replace /"home/app with /var/www/dev.mysite.co/public_html ?

OK, so you have the whole script that I have then. Is your main site in /home/app/throat? Is the contents of that directory what you copied to /var/www/dev.mysite.co/public_html? If so, make sure you're making another copy of this script for the dev site and then change that second-to-last line (starting with cd) to reflect that new directory.

I'm not 100% sure what everything above the cd command is doing. I don't see the HOME, USER, and PATH variables being used elsewhere in this script and it may not actually be doing anything. I don't know enough about that script yet, the person that gave it to you might be able to shed more light on it. Try what I suggested first and see what happens. ¯\(ツ)