Skip to content

Commit c91ac58

Browse files
committed
tweaks
1 parent 81af580 commit c91ac58

File tree

3 files changed

+26
-47
lines changed

3 files changed

+26
-47
lines changed

fabfile.py

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,19 @@ def provision(conn, domain):
3131
conn.run(f"pyenv install {PYTHON_VERSION}")
3232
conn.run(f"pyenv global {PYTHON_VERSION}")
3333

34-
# Tell redis to use systemd
35-
conn.run('sed -i "s/supervised no/supervised systemd/g" /etc/redis/redis.conf')
36-
conn.run("service redis restart")
37-
3834
# Create the `web` user with their own home director and group
39-
conn.run("useradd --create-home --user-group")
35+
conn.run("useradd --create-home --user-group web")
4036

4137
# Clone the repository
42-
conn.run("git clone https://github.com/pipermerriam/ethereum-function-signature-database.git /home/web")
38+
conn.run("git clone https://github.com/pipermerriam/ethereum-function-signature-registry.git /home/web/ethereum-function-signature-registry")
4339

4440
#
4541
# Setup and Install project dependencies
4642
#
4743
conn.run("pip install virtualenv")
4844
conn.run("python -m virtualenv /home/web/venv")
4945

50-
conn.run("/home/web/venv/bin/pip install -r /home/web/ethereum-function-signature-database/requirements.txt")
46+
conn.run("/home/web/venv/bin/pip install -r /home/web/ethereum-function-signature-registry/requirements.txt")
5147

5248
with tempfile.TemporaryDirectory() as base_path:
5349
dotenv_file_path = pathlib.Path(base_path) / '.env'
@@ -57,21 +53,27 @@ def provision(conn, domain):
5753
SECRET_KEY=django_secret_key,
5854
))
5955

60-
conn.put(str(dotenv_file_path), remote='/home/web/ethereum-function-signature-database/.env')
56+
conn.put(str(dotenv_file_path), remote='/home/web/ethereum-function-signature-registry/.env')
57+
58+
59+
Setup Postgres User and Database
6160

62-
#
63-
# Setup Postgres User and Database
64-
#
6561
with tempfile.TemporaryDirectory() as base_path:
6662
# systemd service for worker
6763
pgpass_file_path = pathlib.Path(base_path) / '.pgpass'
68-
pgpass_file_path.write_text(f"*.*.*.4byte.{postgress_password}")
64+
pgpass_file_path.write_text(f"*.*.*.bytes4.{postgres_password}")
6965

7066
conn.put(str(pgpass_file_path), remote='/root/.pgpass')
7167
conn.run("chmod 600 /root/.pgpass")
7268

73-
conn.run(f"sudo -u postgres psql -c 'CREATE ROLE joe PASSWORD \"{postgres_password}\" CREATEDB LOGIN;'")
74-
conn.run("sudo -u postgres createdb --username 4byte --no-password 4byte")
69+
conn.run(f"sudo -u postgres psql -c \"CREATE ROLE bytes4 PASSWORD '{postgres_password}' SUPERUSER LOGIN;\"")
70+
conn.run("sudo -u postgres createdb --no-password bytes4")
71+
72+
#
73+
# Setup Redis
74+
#
75+
conn.run('sed -i "s/supervised no/supervised systemd/g" /etc/redis/redis.conf')
76+
conn.run("service redis restart")
7577

7678
#
7779
# Setup config files for uwsgi/nginx/4byte-worker
@@ -81,7 +83,7 @@ def provision(conn, domain):
8183
worker_service_file_path = pathlib.Path(base_path) / '4byte.service'
8284
worker_service_file_path.write_text(SYSTEMD_WORKER_SERVICE)
8385

84-
conn.put(str(worker_service_file_path), remote='/ect/systemd/system/4byte.service')
86+
conn.put(str(worker_service_file_path), remote='/etc/systemd/system/4byte.service')
8587

8688
# nginx configuration file
8789
nginx_4byte_conf = pathlib.Path(base_path) / '4byte'
@@ -118,12 +120,21 @@ def _append_bashrc(conn, content: str) -> None:
118120
"gpg",
119121
"software-properties-common",
120122
"pkg-config",
123+
"zlib1g",
124+
"zlib1g-dev",
125+
"libbz2-dev",
126+
"libreadline-dev",
127+
"libssl-dev",
128+
"libsqlite3-dev",
129+
"libffi-dev",
121130
# application
122131
"nginx",
123132
"uwsgi",
133+
"uwsgi-plugin-python3",
124134
"redis-server",
125135
"postgresql",
126136
"postgresql-contrib",
137+
"postgresql-server-dev-11",
127138
# convenience
128139
"htop",
129140
"tmux",
@@ -215,10 +226,8 @@ def _append_bashrc(conn, content: str) -> None:
215226
DJANGO_ALLOWED_HOSTS={DOMAIN}
216227
DJANGO_DEBUG=False
217228
DJANGO_DEBUG_TOOLBAR_ENABLED=False
218-
DJANGO_DEFAULT_FILE_STORAGE=s3_folder_storage.s3.DefaultStorage
219229
DJANGO_SECRET_KEY={SECRET_KEY}
220230
DJANGO_SECURE_SSL_REDIRECT=False
221-
DJANGO_STATICFILES_STORAGE=s3_folder_storage.s3.StaticStorage
222231
HUEY_WORKER_TYPE=thread
223232
REDIS_URL=redis://127.0.0.1:6379
224233
"""

func_sig_registry/settings.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@
4646
'func_sig_registry.registry',
4747
'rest_framework',
4848
'django_tables2',
49-
'storages',
50-
's3_folder_storage',
5149
'huey.contrib.djhuey',
5250
'corsheaders',
5351
]
@@ -183,31 +181,6 @@
183181
)
184182

185183

186-
# AWS Configuration
187-
DEFAULT_S3_PATH = "media"
188-
STATIC_S3_PATH = "static"
189-
190-
AWS_ACCESS_KEY_ID = env.get('AWS_ACCESS_KEY_ID', type=str, default=None)
191-
AWS_SECRET_ACCESS_KEY = env.get('AWS_SECRET_ACCESS_KEY', type=str, default=None)
192-
AWS_STORAGE_BUCKET_NAME = env.get('AWS_STORAGE_BUCKET_NAME', type=str, default=None)
193-
AWS_DEFAULT_REGION = env.get('AWS_DEFAULT_REGION', type=str, default=None)
194-
195-
# Boto config
196-
AWS_REDUCED_REDUNDANCY = True
197-
AWS_QUERYSTRING_AUTH = False
198-
AWS_S3_FILE_OVERWRITE = True
199-
AWS_S3_SECURE_URLS = True
200-
AWS_IS_GZIPPED = False
201-
AWS_PRELOAD_METADATA = True
202-
AWS_HEADERS = {
203-
"Cache-Control": "public, max-age=86400",
204-
}
205-
206-
if AWS_DEFAULT_REGION:
207-
# Fix for https://github.com/boto/boto/issues/621
208-
AWS_S3_HOST = "s3-{0}.amazonaws.com".format(AWS_DEFAULT_REGION)
209-
210-
211184
# DRF
212185
REST_FRAMEWORK = {
213186
'DEFAULT_PERMISSION_CLASSES': [

requirements.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ django-tables2>=1.2.3,<1.3.0
33
djangorestframework>=3.3.3,<3.4.0
44
ipython>=6.2.1
55
pysha3==1.0.2
6-
django-s3-folder-storage>=0.3,<0.4
7-
django-storages>=1.4.1,<1.5.0
8-
boto>=2.41.0,<3.0.0
96
env-excavator>=1.5.0,<1.6.0
107
python-dotenv>=0.5.1,<0.6.0
118
psycopg2-binary>=2.7.4,<2.8.0

0 commit comments

Comments
 (0)