my reference: https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/uwsgi/
my project name:
'mysite'
my directories:
I create 'uwsgi.ini'.
then, I written in ini file.
[uwsgi]
chdir=/var/www/html/portfolio/mysite
module=mysite.wsgi:application
master=True
pidfile=/tmp/project-master.pid
vacuum=True
max-requests=5000
daemonize=/var/log/uwsgi/yourproject.log
single-interpreter=True
then, I command 'service apache2 restart'
I command this 'uwsgi --ini uwsgi.ini'
# uwsgi --ini uwsgi.ini
# open("/var/log/uwsgi/yourproject.log"): No such file or directory [core/logging.c line 288]
reference(japanese)
Ubuntu server fails
(console)
# pip3 install uwsgi
Installing collected packages: uwsgi
Successfully installed uwsgi-2.0.20
# mkdir -p /etc/uwsgi/vassals
# cd /etc/uwsgi/vassals
# source /var/www/html/venv/bin/activate
# vi uwsgi.ini
(uwsgi.ini(new))
[uwsgi]
chdir=/var/www/html/portfolio/mysite
module=mysite.wsgi:application
master=True
pidfile=/tmp/project-master.pid
vacuum=True
max-requests=5000
daemonize=/var/log/uwsgi/uwsgi.log
single-interpreter=True
(console)
# adduser --group uwsgi-data
# adduser --home /etc/uwsgi --no-create-home --shell /sbin/nologin --ingroup uwsgi-data --disabled-login uwsgi-data
Adding user `uwsgi-data' ...
Adding new user `uwsgi-data' (1001) with group `uwsgi-data' ...
Not creating home directory `/etc/uwsgi'.
Changing the user information for uwsgi-data
Enter the new value, or press ENTER for the
default
Full Name []: # Empty and OK
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] Y
(console)
# chown -R uwsgi-data:uwsgi-data /etc/uwsgi
# mkdir /var/log/uwsgi
# chown -R uwsgi-data:uwsgi-data /var/log/uwsgi
# vi /etc/systemd/system/emperor.uwsgi.service
(emperor.uwsgi.service)
[Unit]
Description=uWSGI Emperor
After=syslog.service
[Service]
# Find the configuration file that exists in "/etc/uwsgi/vassals" and start the uWSGI daemon.
ExecStart=/var/www/html/venv/bin/uwsgi --master --emperor /etc/uwsgi/vassals
RuntimeDirectory=uwsgi
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target
(console)
# chmod 755 /etc/systemd/system/emperor.uwsgi.service
# vi /etc/uwsgi/vassals/emperor.ini
(emperor.ini)
[uwsgi]
emperor = /etc/uwsgi/vassals
uid = uwsgi-data
gid = uwsgi-data
(console)
# systemctl start emperor.uwsgi.service
# systemctl status emperor.uwsgi.service
● emperor.uwsgi.service - uWSGI Emperor
Loaded: loaded (/etc/systemd/system/emperor.uwsgi.service; disabled; vendor preset: enabled)
Active: active (running)
# service apache2 restart
Related
I've been trying to mount a Google Cloud bucket inside a pod in our (onprem) cluster in order to share that mounted volume using NFS to other pods and PersistentVolumes.
Here there are the configurations:
#!/bin/bash
_start_nfs() {
exportfs -a
rpcbind
rpc.statd
rpc.nfsd
rpc.mountd
GOOGLE_APPLICATION_CREDENTIALS=/accounts/key.json gcsfuse -o allow_other --dir-mode 777 --uid 1500 --gid 1500 ${BUCKET} /exports
}
_nfs_server_mounts() {
IFS=':' read -r -a MNT_SERVER_ARRAY <<< "$NFS_SERVER_DIRS"
for server_mnt in "${MNT_SERVER_ARRAY[#]}"; do
if [[ ! -d $server_mnt ]]; then
mkdir -p $server_mnt
fi
chmod -R 777 $server_mnt
cat >> /etc/exports <<EOF
${server_mnt} *(rw,sync,no_subtree_check,all_squash,anonuid=1500,anongid=1500,fsid=$(( ( RANDOM % 100 ) + 200 )))
EOF
done
cat /etc/exports
}
_sysconfig_nfs() {
cat > /etc/sysconfig/nfs <<EOF
#
#
# To set lockd kernel module parameters please see
# /etc/modprobe.d/lockd.conf
#
# Optional arguments passed to rpc.nfsd. See rpc.nfsd(8)
RPCNFSDARGS=""
# Number of nfs server processes to be started.
# The default is 8.
RPCNFSDCOUNT=${RPCNFSDCOUNT}
#
# Set V4 grace period in seconds
#NFSD_V4_GRACE=90
#
# Set V4 lease period in seconds
#NFSD_V4_LEASE=90
#
# Optional arguments passed to rpc.mountd. See rpc.mountd(8)
RPCMOUNTDOPTS=""
# Port rpc.mountd should listen on.
#MOUNTD_PORT=892
#
# Optional arguments passed to rpc.statd. See rpc.statd(8)
STATDARG=""
# Port rpc.statd should listen on.
#STATD_PORT=662
# Outgoing port statd should used. The default is port
# is random
#STATD_OUTGOING_PORT=2020
# Specify callout program
#STATD_HA_CALLOUT="/usr/local/bin/foo"
#
#
# Optional arguments passed to sm-notify. See sm-notify(8)
SMNOTIFYARGS=""
#
# Optional arguments passed to rpc.idmapd. See rpc.idmapd(8)
RPCIDMAPDARGS=""
#
# Optional arguments passed to rpc.gssd. See rpc.gssd(8)
# Note: The rpc-gssd service will not start unless the
# file /etc/krb5.keytab exists. If an alternate
# keytab is needed, that separate keytab file
# location may be defined in the rpc-gssd.service's
# systemd unit file under the ConditionPathExists
# parameter
RPCGSSDARGS=""
#
# Enable usage of gssproxy. See gssproxy-mech(8).
GSS_USE_PROXY="yes"
#
# Optional arguments passed to blkmapd. See blkmapd(8)
BLKMAPDARGS=""
EOF
}
### main ###
_sysconfig_nfs
_nfs_server_mounts
_start_nfs
rpcinfo -p
showmount -e
tail -f /dev/null
The Dockerfile:
FROM centos:7
RUN yum -y install /usr/bin/ps nfs-utils nfs4-acl-tools curl portmap fuse nfs-utils && yum clean all
RUN mkdir -p /exports
ENV RPCNFSDCOUNT=8 \
NFS_SERVER_DIRS='/usr'
RUN chown nfsnobody:nfsnobody /exports
RUN chmod 777 /exports
ADD setup.sh /usr/local/bin/run_nfs.sh
RUN chmod +x /usr/local/bin/run_nfs.sh
RUN useradd -u 1500 orenes
ADD gcsfuse-0.41.6-1.x86_64.rpm /data/gcsfuse-0.41.6-1.x86_64.rpm
RUN yum install -y /data/gcsfuse-0.41.6-1.x86_64.rpm
# Expose volume
VOLUME ["/exports"]
# expose mountd 20048/tcp and nfsd 2049/tcp and rpcbind 111/tcp
EXPOSE 2049/tcp 20048/tcp 111/tcp 111/udp
ENTRYPOINT ["/usr/local/bin/run_nfs.sh"]
Let's assume that there's a PersistentVolume mounting a Service pointing to the NFS server I described before.
So far I got access denied, unable to receive, etc...
Should I move to a SMB/CIFS sharing? Is there any solution on this? Thanks in advance.
It seems that FUSE and NFS don't get well along. I ended up using SMB and it works flawlessly but you must use the Service ClusterIP instead of Kubernetes's DNS.
The comment from #AviD about using a CSI is so helpful if you need to make it quick.
Again thanks to all.
overview
uwsgi emperor is enabled but not working numpy on ubuntu.
Why doesn't it work? My portfolio is useless.
I tried a lot but I don't understand anymore
emperor.uwsgi.service - uWSGI Emperor
Loaded: loaded (/etc/systemd/system/emperor.uwsgi.service; disabled; vendor preset: enabled)
Active: active (running) since Sat 2022-03-19 22:15:50 JST; 12h ago
Main PID: 435890 (uwsgi)
Status: "The Emperor is governing 1 vassals"
Tasks: 462 (limit: 462)
Memory: 119.8M
CGroup: /system.slice/emperor.uwsgi.service
├─435890 /var/www/html/venv/bin/uwsgi --master --emperor /etc/uwsgi/vassals
├─435899 /var/www/html/venv/bin/uwsgi --master --emperor /etc/uwsgi/vassals
settings
uwsgi.ini
[uwsgi]
chdir=/var/www/html/portfolio/mysite
module=mysite.wsgi:application
master=True
pidfile=/tmp/project-master.pid
vacuum=True
max-requests=5000
daemonize=/var/log/uwsgi/uwsgi.log
single-interpreter=True
add user
# adduser --group uwsgi-data
# adduser --home /etc/uwsgi --no-create-home --shell /sbin/nologin --ingroup uwsgi-data --disabled-login uwsgi-data
change permission
# chown -R uwsgi-data:uwsgi-data /etc/uwsgi
# mkdir /var/log/uwsgi
# chown -R uwsgi-data:uwsgi-data /var/log/uwsgi
create a service file emperor.uwsgi.service
[Unit]
Description=uWSGI Emperor
After=syslog.service
[Service]
# 「/etc/uwsgi/vassals」に存在する設定ファイルを探しuWSGIデーモンを起動する
ExecStart=/var/www/html/venv/bin/uwsgi --master --emperor /etc/uwsgi/vassals
RuntimeDirectory=uwsgi
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target
emperor.ini
[uwsgi]
emperor = /etc/uwsgi/vassals
uid = uwsgi-data
gid = uwsgi-data
turn on
# systemctl start emperor.uwsgi.service
# systemctl status emperor.uwsgi.service
● emperor.uwsgi.service - uWSGI Emperor
Loaded: loaded (/etc/systemd/system/emperor.uwsgi.service; disabled; vendor preset: enabled)
Active: active (running)
# service apache2 restart
I know the error message socket.error: [Errno 98] Address already in use means that a port is already being used, but I cannot figure out why port 5000 is already being used.
I run into this error when running:
docker build -t mm-api .;
docker run -it \
-e DB_HOST_IP=$DEFAULT_DB_HOST_IP \
-e DB_HOST_USER=$DEFAULT_DB_HOST_USER \
-e DB_HOST_PASS=$DEFAULT_DB_HOST_PASS \
-e DB_HOST_SCHEMA=$DEFAULT_DB_HOST_SCHEMA \
-p 0.0.0.0:5001:5000 mm-api;
This is the error I run into:
2019-05-21 21:28:37,804 CRIT uncaptured python exception, closing channel <POutputDispatcher at 139680364456560 for <Subprocess at 139680363965760 with name uwsgi in state RUNNING> (stdout)> (<type 'exceptions.IOError'>:[Errno 29] Illegal seek [/usr/lib/python2.7/dist-packages/supervisor/supervisord.py|runforever|227] [/usr/lib/python2.7/dist-packages/supervisor/dispatchers.py|handle_read_event|232] [/usr/lib/python2.7/dist-packages/supervisor/dispatchers.py|record_output|166] [/usr/lib/python2.7/dist-packages/supervisor/dispatchers.py|_log|142] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|info|275] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|log|293] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|emit|186] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|doRollover|211])
* Serving Flask app "uwsgi_file_app" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: on
2019-05-21 21:28:37,807 CRIT uncaptured python exception, closing channel <POutputDispatcher at 139680364456560 for <Subprocess at 139680363965760 with name uwsgi in state RUNNING> (stdout)> (<type 'exceptions.IOError'>:[Errno 29] Illegal seek [/usr/lib/python2.7/dist-packages/supervisor/supervisord.py|runforever|227] [/usr/lib/python2.7/dist-packages/supervisor/dispatchers.py|handle_read_event|232] [/usr/lib/python2.7/dist-packages/supervisor/dispatchers.py|record_output|166] [/usr/lib/python2.7/dist-packages/supervisor/dispatchers.py|_log|142] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|info|275] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|log|293] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|emit|186] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|doRollover|211])
Traceback (most recent call last):
File "app.py", line 29, in <module>
app.run(host='0.0.0.0', port=5000, debug=True)
File "/usr/local/lib/python2.7/dist-packages/connexion/apps/flask_app.py", line 93, in run
2019-05-21 21:28:37,821 CRIT uncaptured python exception, closing channel <POutputDispatcher at 139680364014912 for <Subprocess at 139680363965760 with name uwsgi in state RUNNING> (stderr)> (<type 'exceptions.IOError'>:[Errno 29] Illegal seek [/usr/lib/python2.7/dist-packages/supervisor/supervisord.py|runforever|227] [/usr/lib/python2.7/dist-packages/supervisor/dispatchers.py|handle_read_event|232] [/usr/lib/python2.7/dist-packages/supervisor/dispatchers.py|record_output|166] [/usr/lib/python2.7/dist-packages/supervisor/dispatchers.py|_log|142] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|info|275] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|log|293] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|emit|186] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|doRollover|211])
self.app.run(self.host, port=self.port, debug=self.debug, **options)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 944, in run
2019-05-21 21:28:37,822 CRIT uncaptured python exception, closing channel <POutputDispatcher at 139680364014912 for <Subprocess at 139680363965760 with name uwsgi in state RUNNING> (stderr)> (<type 'exceptions.IOError'>:[Errno 29] Illegal seek [/usr/lib/python2.7/dist-packages/supervisor/supervisord.py|runforever|227] [/usr/lib/python2.7/dist-packages/supervisor/dispatchers.py|handle_read_event|232] [/usr/lib/python2.7/dist-packages/supervisor/dispatchers.py|record_output|166] [/usr/lib/python2.7/dist-packages/supervisor/dispatchers.py|_log|142] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|info|275] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|log|293] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|emit|186] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|doRollover|211])
run_simple(host, port, self, **options)
File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 987, in run_simple
2019-05-21 21:28:37,823 CRIT uncaptured python exception, closing channel <POutputDispatcher at 139680364014912 for <Subprocess at 139680363965760 with name uwsgi in state RUNNING> (stderr)> (<type 'exceptions.IOError'>:[Errno 29] Illegal seek [/usr/lib/python2.7/dist-packages/supervisor/supervisord.py|runforever|227] [/usr/lib/python2.7/dist-packages/supervisor/dispatchers.py|handle_read_event|232] [/usr/lib/python2.7/dist-packages/supervisor/dispatchers.py|record_output|166] [/usr/lib/python2.7/dist-packages/supervisor/dispatchers.py|_log|142] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|info|275] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|log|293] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|emit|186] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|doRollover|211])
2019-05-21 21:28:37,823 CRIT uncaptured python exception, closing channel <POutputDispatcher at 139680364014912 for <Subprocess at 139680363965760 with name uwsgi in state RUNNING> (stderr)> (<type 'exceptions.IOError'>:[Errno 29] Illegal seek [/usr/lib/python2.7/dist-packages/supervisor/supervisord.py|runforever|227] [/usr/lib/python2.7/dist-packages/supervisor/dispatchers.py|handle_read_event|232] [/usr/lib/python2.7/dist-packages/supervisor/dispatchers.py|record_output|166] [/usr/lib/python2.7/dist-packages/supervisor/dispatchers.py|_log|142] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|info|275] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|log|293] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|emit|186] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|doRollover|211])
s.bind(server_address)
File "/usr/lib/python2.7/socket.py", line 228, in meth
2019-05-21 21:28:37,824 CRIT uncaptured python exception, closing channel <POutputDispatcher at 139680364014912 for <Subprocess at 139680363965760 with name uwsgi in state RUNNING> (stderr)> (<type 'exceptions.IOError'>:[Errno 29] Illegal seek [/usr/lib/python2.7/dist-packages/supervisor/supervisord.py|runforever|227] [/usr/lib/python2.7/dist-packages/supervisor/dispatchers.py|handle_read_event|232] [/usr/lib/python2.7/dist-packages/supervisor/dispatchers.py|record_output|166] [/usr/lib/python2.7/dist-packages/supervisor/dispatchers.py|_log|142] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|info|275] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|log|293] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|emit|186] [/usr/lib/python2.7/dist-packages/supervisor/loggers.py|doRollover|211])
return getattr(self._sock,name)(*args)
socket.error: [Errno 98] Address already in use
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
Dockerfile:
FROM ubuntu:18.04
ARG APP_DIR="/opt/media-management/app"
ARG DB_HOST_IP
ARG DB_HOST_USER
ARG DB_HOST_PASS
ARG DB_HOST_SCHEMA
ARG DB_SERVICE_NAME
ARG AWS_ACCESS_KEY
ARG AWS_SECRET_KEY
ARG AWS_BUCKET_NAME
ARG IMAGE_BUCKET_NAME
ARG FTP_HOST_NAME
ARG FTP_USER_NAME
ARG FTP_PASSWORD
ARG IMAGE_SERVICE_HOST_NAME
ARG IMAGE_SERVICE_ROOT_PATH
ARG INGESTION_API_HOST_NAME
ARG NGINX_SERVICE_PORT="5000"
RUN apt-get update && apt-get -y upgrade
RUN apt-get install -y python-setuptools && apt-get install -y python-dev build-essential && apt-get install -y python-pip
RUN apt-get update --fix-missing && apt-get -y install unixodbc-dev && apt-get install -y imagemagick vim bpython nginx uwsgi uwsgi-plugin-python supervisor
RUN apt-get install -y build-essential libssl-dev libffi-dev python-dev
RUN apt-get install -y libxml2-dev libxslt1-dev python-dev
RUN pip install --upgrade pip && pip install awscli && pip install pyodbc & pip install cryptography
RUN pip install --upgrade setuptools
RUN apt-get install -y freetds-bin freetds-common freetds-dev libct4 libsybdb5
RUN apt-get install -y tdsodbc
RUN apt-get update
RUN mkdir -p $APP_DIR && \
mkdir -p /mnt/downloads && \
mkdir -p /mnt/logging
ADD requirements.txt $APP_DIR/
RUN pip install -r $APP_DIR/requirements.txt
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
# Copy all the application's source files to the container image
ADD . $APP_DIR
# Initialize all the needed environment variables
ENV DB_HOST_IP=$DB_HOST_IP
ENV DB_HOST_USER=$DB_HOST_USER
ENV DB_HOST_PASS=$DB_HOST_PASS
ENV DB_HOST_SCHEMA=$DB_HOST_SCHEMA
ENV DB_SERVICE_NAME=$DB_SERVICE_NAME
ENV AWS_ACCESS_KEY=$AWS_ACCESS_KEY
ENV AWS_SECRET_KEY=$AWS_SECRET_KEY
ENV AWS_BUCKET_NAME=$AWS_BUCKET_NAME
ENV IMAGE_BUCKET_NAME=$IMAGE_BUCKET_NAME
ENV FTP_HOST_NAME=$FTP_HOST_NAME
ENV FTP_USER_NAME=$FTP_USER_NAME
ENV FTP_PASSWORD=$FTP_PASSWORD
ENV IMAGE_SERVICE_HOST_NAME=$IMAGE_SERVICE_HOST_NAME
ENV IMAGE_SERVICE_ROOT_PATH=$IMAGE_SERVICE_ROOT_PATH
ENV INGESTION_API_HOST_NAME=$INGESTION_API_HOST_NAME
ENV NGINX_SERVICE_PORT="5000"
ENV APP_DIR=$APP_DIR
ENV CONFIG_DIR="$APP_DIR/config"
RUN ln -s /mnt/logging $APP_DIR/logging && \
touch $APP_DIR/logging/media-management.log && \
touch $APP_DIR/access.log && \
touch $APP_DIR/errors.log
WORKDIR $APP_DIR
RUN chmod +x setup.sh templater.sh
ENV PYTHONPATH="${PYTHONPATH}:${APP_DIR}"
EXPOSE 5000
ENTRYPOINT ["/bin/bash", "-c", "./setup.sh; /usr/bin/supervisord -c $CONFIG_DIR/supervisord.conf"]
setup.sh:
#!/usr/bin/env bash
echo "Copying config files to expected locations...";
cp $CONFIG_DIR/freetds.conf /etc/freetds/;
cp $CONFIG_DIR/odbc.ini /etc/;
cp $CONFIG_DIR/nginx.conf /etc/nginx/conf.d/;
cp $CONFIG_DIR/supervisord.conf /etc/supervisor/conf.d/;
echo "Installing more config to the odbc.ini file...";
odbcinst -i -d -f $CONFIG_DIR/odbcinst.ini
freetds.conf:
# This file is installed by FreeTDS if no file by the same
# name is found in the installation directory.
#
# For information about the layout of this file and its settings,
# see the freetds.conf manpage "man freetds.conf".
# Global settings are overridden by those in a database
# server specific section
[global]
# TDS protocol version
; tds version = 4.2
# Whether to write a TDSDUMP file for diagnostic purposes
# (setting this to /tmp is insecure on a multi-user system)
; dump file = /tmp/freetds.log
; debug flags = 0xffff
# Command and connection timeouts
timeout = 10
; connect timeout = 10
# If you get out-of-memory errors, it may mean that your client
# is trying to allocate a huge buffer for a TEXT field.
# Try setting 'text size' to a more reasonable limit
text size = 64512
# The basics for defining a DSN (Data Source Name)
# [data_source_name]
# # host = <hostname or IP address>
# # port = <port number to connect to - probably 1433>
# # tds version = <TDS version to use - probably 8.0>
#
# # Define a connection to the Microsoft SQL Server
[MSSQL]
host = {{DB_HOST_IP}}
port = 1433
tds version = 8.0
AnsiNPW = YES
QuotedID = YES
nginx.conf:
server {
underscores_in_headers on;
client_max_body_size 6000M;
listen 0.0.0.0:5000;
listen [::]:5000;
location / {
include uwsgi_params;
uwsgi_pass unix:///tmp/uwsgi.sock;
uwsgi_read_timeout 600s;
uwsgi_send_timeout 600s;
access_log {{APP_DIR}}/access.log;
error_log {{APP_DIR}}/errors.log warn;
}
}
odbc.ini:
# Define a connection to a Microsoft SQL server
# The Description can be whatever we want it to be.
# The Driver value must match what we have defined in /etc/odbcinst.ini
# The Database name must be the name of the database this connection will connect to.
# The ServerName is the name we defined in /etc/freetds/freetds.conf
# The TDS_Version should match what we defined in /etc/freetds/freetds.conf
[mssql]
Description = MSSQL Server
Driver = FreeTDS
Database = {{DB_HOST_SCHEMA}}
Server = {{DB_HOST_IP}}
Port = 1433
TDS_Version = 8.0
odbcinst.ini:
[FreeTDS]
Description=FreeTDS Driver
Driver=/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup=/usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
supervisord.conf:
[supervisord]
nodaemon=true
[program:uwsgi]
command=/usr/bin/uwsgi --ini {{CONFIG_DIR}}/uwsgi.ini
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=10000
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=10000
[program:nginx]
command=/usr/sbin/nginx
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=10000
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=10000
uwsgi.ini:
[uwsgi]
socket = /tmp/uwsgi.sock
chown-socket = www-data:adm
chmod-socket = 664
cheaper-algo = spare
cheaper = 2
cheaper-initial = 4
workers = 8
cheaper-step = 1
callable = app
plugin = python
chdir=/opt/media-management/app
pythonpath=/opt/media-management/app
wsgi-file=app.py
app.py:
import os
import connexion
from flask_cors import CORS
app = connexion.App(__name__, specification_dir='./swagger/', debug=True)
app.add_api('swagger.yaml', arguments={'title': 'API Service'})
CORS(app.app)
if __name__ in ['__main__', 'uwsgi_file_app']:
app.run(host='0.0.0.0', port=5000, debug=True)
I cannot understand why that port is already being used, but I suspect it has something to do with the way uWSGI is being setup. Please help, thank you!
I think Nginx and Flask run on the same port 5000 in a container.
If you want uWSGI to start your application, it is no need to use app.run(host='0.0.0.0', port=5000, debug=True) this line.
I don't succeed providing a dockerfile via Vagrant on Windows. If I use an image (e.g. d.image = "phusion/baseimage" instead of build_dir everything is fine - but when building from a dockerfile (as shown in the vagrantfile below) - I get the following error (of course I have a Dockerfile in infrastructure/ssh-docker!):
PS C:\privat\cloud-backup\cloud-backup-for-podio> vagrant up
Bringing machine 'app' up with 'docker' provider...
==> app: Docker host is required. One will be created if necessary...
app: Docker host VM is already ready.
==> app: Syncing folders to the host VM...
app: Preparing SMB shared folders...
app: Mounting SMB shared folders...
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/guests/linux/cap/choose_addressable_ip_addr.rb:7:in `block
in choose_addressable_ip_addr': undefined method `each' for nil:NilClass (NoMethodError)
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/guests/linux/cap/choose_addressable_ip_addr.rb:6:in `tap'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/guests/linux/cap/choose_addressable_ip_addr.rb:6:in `choose_addressable_ip_addr'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/capability_host.rb:111:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/capability_host.rb:111:in `capability'
...
Vagrantfile:
Vagrant.configure("2") do |config
config.ssh.username = 'vagrant'
config.ssh.password = 'tcuser'
config.ssh.port = 22
config.vm.define "app" do |app|
app.vm.synced_folder ".", "/vagrant", type: "smb", smb_host: "MY_IP", smb_username: "WINUSER#DOMAIN", smb_password: "WINPASSWORD"
app.vm.provider "docker" do |d|
#d.image = "phusion/baseimage"
d.build_dir = "infrastructure/ssh-docker"
d.name = "app"
d.remains_running = true
end
end
end
Dockerfile:
FROM phusion/baseimage
ENV HOME /root
# enable ssh
RUN rm -f /etc/service/sshd/down
# Regenerate SSH host keys. baseimage-docker does not contain any, so you
# have to do that yourself. You may also comment out this instruction; the
# init system will auto-generate one during boot.
RUN /etc/my_init.d/00_regen_ssh_host_keys.sh
# Use baseimage-docker's init system.
CMD ["/sbin/my_init"]
RUN apt-get update
RUN apt-get install -y openssh-server wget lsb-release sudo
EXPOSE 22
RUN mkdir -p /var/run/sshd
RUN chmod 0755 /var/run/sshd
# Create and configure vagrant user
RUN useradd --create-home -s /bin/bash vagrant
WORKDIR /home/vagrant
# Configure SSH access
RUN mkdir -p /home/vagrant/.ssh
RUN echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key" > /home/vagrant/.ssh/authorized_keys
RUN chown -R vagrant: /home/vagrant/.ssh
RUN echo -n 'vagrant:vagrant' | chpasswd
# Enable passwordless sudo for the "vagrant" user
RUN mkdir -p /etc/sudoers.d
RUN install -b -m 0440 /dev/null /etc/sudoers.d/vagrant
RUN echo 'vagrant ALL=NOPASSWD: ALL' >> /etc/sudoers.d/vagrant
# Clean up APT when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
Vagrant version: 1.7.4
Anyone has some idea?
(What I need to do is run a docker image from a dockerfile and have a shared/synced directory..)
You should provide your ip in for smb service
config.vm.synced_folder ".", "/home/vagrant/github-api", type: 'smb', smb_host: "192.168.1.100"
I have running uwsgi server. i need log rotation for daily and file size based log rotation.
uwsgi configuration:
# file: /etc/init/uwsgi.conf
description "uWSGI starter"
start on (local-filesystems and runlevel [2345])
stop on runlevel [016]
respawn
# home - is the path to our virtualenv directory
# pythonpath - the path to our django application
# module - the wsgi handler python script
exec /home/testuser/virtual_environments/teatapp/bin/uwsgi \
--uid testuser \
--home /home/testuser/virtual_environments/teatapp \
--pythonpath /home/testuser/sci-github/teatapp\
--socket /tmp/uwsgi.sock \
--chmod-socket \
--module wsgi \
--logdate \
--optimize 2 \
--processes 2 \
--master \
--logto /var/log/uwsgi/uwsgi.log
logrotate configuration:
# file : /etc/logrotate.conf
"/var/log/uwsgi/*.log" {
copytruncate
daily
maxsize 5k
dateext
rotate 5
compress
missingok
create 777 root root
}
But log rotation is not working please give the solution for if any wrong configuration in logrotaion.conf.
It's not needed to restart uwsgi service if you use copytruncate option in logrotate file (as stated by Tamar).
But the problem may be that you forgot to enable logrotate in cron. Please, make sure you have a entry in /etc/cron.daily called logrotate.
there is logrotation in uwsgi, based on the log file size, for example (uwsgi.ini directive):
log-maxsize = 100000
if you want to use logrotated, you have to restart uwsgi (logrotate directives):
postrotate
stop uwsgi
start uwsgi
endscript
Just put this on your uwsgi configuration file :
daemonize = /var/log/uwsgi/uwsgi-#(exec://date +%%Y-%%m-%%d).log
This will create a log each day, but be carefull don't daemonize if you are using master our emperror. Then if the logs are big you can control it with a script attatched to a cron to clean the folder.