Commit 5754a2ef by Owo Sugiana

README yang lebih baik

1 parent 9ed427fa
......@@ -99,7 +99,7 @@ ENV/
# Rope project settings
.ropeproject
*.ini
live.ini
.idea/
.project/
.DS_Store
......@@ -118,5 +118,5 @@ opensipkd/base/static/icon/*
alembic.ini
alembic_local.ini
.vs/
.vscode/
.vs*
activate
No preview for this file type
No preview for this file type
File mode changed
include *.txt *.ini *.cfg *.rst *.tpl *.csv *.ttf *.woff *.woff2 *.svg
recursive-include opensipkd *.ico *.png *.css *.gif *.jpg *.pt *.txt
recursive-include opensipkd *.js *.html *.xml *.csv *.ttf *.woff *.woff2 *.svg
include *.txt *.ini *.rst *.tpl *.csv *.ttf *.woff *.woff2 *.svg
recursive-include opensipkd *.ico *.png *.css *.gif *.jpg *.pt *.txt *.js *.html *.xml *.csv *.ttf *.woff *.woff2 *.svg
# Basis Aplikasi openSIPKD
Ini adalah basis dari seluruh aplikasi openSIPKD.
# Pemasangan
## Pasang paket Debian yang dibutuhkan::
$ sudo apt install libxml2-dev libxslt1-dev libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev
## Buat Python Virtual Environment:
Biasanya pada home directory::
$ python3 -m venv ~/env
$ ~/env/bin/pip install --upgrade pip setuptools
$ ~/env/bin/pip install wheel
## Instalasi
### Production:
$ ~/env/bin/pip install git+https://git.opensipkd.com/aa.gusti/base.git@latest
$ cp ~/env/etc/live_opensipkd.tpl ~/env/etc/live_opensipkd.ini
### Install Development::
$ source ~/env/bin/activate
$ mkdir apps
$ cd apps
$ git clone https://git.opensipkd.com/aa.gusti/base.git@latest
$ env/bin/pip install -e base[dev]
$ cp ~/env/etc/test_opensipkd.tpl ~/env/etc/test_opensipkd.ini
## Sesuaikan konfigurasi
Konfigurasi tergantung pada jenis instalasi ``test_opensipkd.ini`` atau
``live_opensipkd.ini``pada baris berikut ini::
### Database Koneksi:
[app:main]
sqlalchemy.url = postgresql://user:password@localhost:5432/db
session.url = postgresql://user:password@localhost:5432/db
[alembic_ziggurat]
sqlalchemy.url = postgresql://user:password@localhost:5432/db
script_location = ziggurat_foundation:migration
[alembic_base]
sqlalchemy.url = postgresql://user:password@localhost:5432/db
script_location = opensipkd.base:alembic
### Login/Register:
[app:main]
captcha_files=
# static folder untuk image captcha
reg_captcha = 1
# saat registrasi diwajibkan menggunakan captcha
reg_idcard = 1
# saat registrasi diwajibkan mengisi kode/nik pengguna
# akan menampilkan pula upload file id card
reg_verify = 1
# Registrasi memrlukan verifikasi terlebih dahulu sebelum dapat login
reg_form =
# diisi route registrasi default "register" jika dikosongkan
login_tpl =
# diisi nama template login apabila akan menggunakan template yang berbeda
### Handling Log File:
Logging dapat dilakukan console, file atau tabel
>> Module yang akan di logging
[loggers]
keys = root, opensipkd, sqlalchemy
>> output handler gunakan sesuai kebutuhan tidak perlu semuanya
[handlers]
keys = console, file, table
>> output handler gunakan INFO pada level kalau sedang testing
[logger_opensipkd]
level = WARN
handlers = file, table
qualname = opensipkd
[handler_table]
class = opensipkd.base.handlers.SQLAlchemyHandler
args = ()
level = NOTSET #Sebaiknya hanya gunakan NOTSET atau WARN
formatter = generic
[handler_file]
class = FileHandler
args = ('/full/path/file.log', 'a')
level = NOTSET #Sebaiknya hanya gunakan NOTSET atau WARN
formatter = generic
[alembic]
sqlalchemy.url = postgresql://user:password@localhost:5432/db
script_location = alembic
```
### Google Integrated dan Custom Register Form
Aplikasi sudah bisa terintegrsi dengan google oauth2
Konfigurasi merupakan bagian dari "main"
```
[app:main]
allow_register = True
google-signin-client-id = id oauth2 client dari google
```
## Buat tabelnya::
Perintah untuk membuat tabel
$ ~/env/bin/initialize_opensipkd_db [file_config]
Contoh:
$ ~/env/bin/initialize_opensipkd_db ~/env/etc/test_opensipkd.ini
##Jalankan::
$ ~/env/bin/pserve --reload test.ini
# Penggunaan Proxy
## Apache::
Tambahkan line berikut ini didalam ``<VirtualHost>``::
```
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://server:port/
ProxyPassReverse / http://server:port/
<Proxy *>
allow from all
</Proxy>
```
Contoh::
```
<VirtualHost ip:80>
SuexecUserGroup "#uid" "#gid"
ServerName antrian.opensipkd.com
ServerAlias www.antrian.opensipkd.com
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://localhost:6552/
ProxyPassReverse / http://localhost:6552/
<Proxy *>
allow from all
</Proxy>
</VirtualHost>
```
# Migrasi
Karena ada penambahan dari fungsi table route berfungsi sebagai menu
generator, maka diperlukan upgrade khusus bagi aplikasi lama
```
alembic -c config_file -n alembic_models upgrade head
```
Tambahkan Konfigurasi berikut ini
```
[alembic_models]
sqlalchemy.url = postgresql://user:password@localhost:5432/db
script_location = opensipkd.models:alembic
```
# Virtual Directory
## Setting Ini File
### Ubah `[app:main]` jadi `[app:opensipkd]`
```
;[app:main]
[app:opensipkd_base]
trusted_proxy_headers = "forwarded x-forwarded-for x-forwarded-host x-forwarded-proto x-forwarded-port"
url_prefix='/virtualdir' ; nama cirtual direktory
```
Tambahkan blok berikut ini dibawah ini file
```
[filter:proxy-prefix]
use = egg:PasteDeploy#prefix
prefix = /virtualdir ; nama virtual directory
[pipeline:main]
pipeline =
proxy-prefix
opensipkd_base
```
## Nginx::
```
location /virtualdir{
return 302 /virtualdir/;
}
location /virtualdir/ {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Forwarded-Port $server_port;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 60s;
proxy_send_timeout 90s;
proxy_read_timeout 90s;
proxy_buffering off;
proxy_temp_file_write_size 64k;
proxy_pass http://127.0.0.1:6543/;
proxy_redirect off;
}
```
Other Configuration
```
[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 6543
;port = %(http_port)s digunakan jika port akan menggunakan parameter
trusted_proxy = 10.8.50.23
trusted_proxy_count = 1
trusted_proxy_headers = x-forwarded-for x-forwarded-host x-forwarded-proto x-forwarded-port
clear_untrusted_proxy_headers = yes
url_scheme = https # HTTP or https
```
\ No newline at end of file
Basis Aplikasi OpenSIPKD
========================
Ini adalah basis dari seluruh aplikasi openSIPKD.
Pemasangan
----------
Pasang paket Debian yang dibutuhkan::
$ sudo apt install libxml2-dev libxslt1-dev libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev
Buat Python Virtual Environment::
$ python3.12 -m venv ~/env
$ ~/env/bin/pip install --upgrade pip setuptools wheel
Unduh source-nya::
$ git clone https://git.opensipkd.com/aa.gusti/opensipkd-base -b beta-4.2
Pasang::
$ ~/env/bin/pip install opensipkd-base/
Buat databasenya. Lalu salin file konfigurasi::
$ cp bphtb/development.ini live.ini
Sesuaikan database profile dan log file. Lalu buat tabelnya::
$ ~/env/bin/initialize_opensipkd_db live.ini
Jalankan web server::
$ ~/env/bin/pserve live.ini
Di web browser buka `http://localhost:6543/login <http://localhost:6543>`_
Bila Digunakan di Paket Lain
----------------------------
Di paket lainnya pada file ``pyproject.toml`` section ``[project]`` baris ``dependencies`` tambahkan::
dependencies = [
...
'opensipkd-base @ git+https://git.opensipkd.com/aa.gusti/opensipkd-base.git#beta-4.2',
]
Paket Pendukung
---------------
sudo apt-get install libxml2-dev libxslt1-dev libtiff4-dev libjpeg8-dev
sudo apt-get install zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev
venv/bin/activate
\ No newline at end of file
[app:main]
use = egg:opensipkd_base
reload_templates = true
devel = true
debug_authorization = false
debug_notfound = false
debug_routematch = false
debug_templates = true
default_locale_name = en
sqlalchemy.url = postgresql://user:pass@localhost/db
sqlalchemy.echo = true
pyramid.includes =
pyramid_tm
pyramid_beaker
pyramid_chameleon
pyramid_rpc.jsonrpc
session.type = ext:database
session.secret = s0s3cr3t
session.cookie_expires = true
session.key = WhatEver
session.url = postgresql://user:pass@localhost/db
session.timeout = 3000
session.lock_dir = %(here)s/tmp
timezone = Asia/Jakarta
localization = id_ID.UTF-8
#localization = Indonesian_indonesia.1252
#localization = English_Australia.1252
static_files = %(here)s/../files
captcha_files = %(here)s/tmp/captcha
company = Opensipkd
ibukota = Bekasi
departement = IT
address_1 = Jalan....
address_2 = Bekasi ...
center.phone = 021123456789
center.mobile = 081311045668
center.email = aa.gustiana@gmail.com
center.email_password =
center.smtp_server =
_host =
unoconv_py = C:\Program Files\LibreOffice 5\program\python.exe
unoconv_bin = C:\project\toko\env\Scripts\unoconv
modules =
menus =
app_name = Base Opensipkd.com
allow_register = False
change_unit = False
departemen_chg_id = 3
[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 6543
# Begin logging configuration
[loggers]
keys = root, opensipkd, sqlalchemy
[handlers]
keys = console, filelog, tabel
[formatters]
keys = generic
[logger_root]
level = INFO
handlers = console, filelog, tabel
[logger_opensipkd]
level = INFO
handlers =
qualname = opensipkd
[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine
# "level = INFO" logs SQL queries.
# "level = DEBUG" logs SQL queries and results.
# "level = WARN" logs neither. (Recommended for production systems.)
[handler_filelog]
class = FileHandler
args = ('/home/aagusti/log/web.log','a')
level = INFO
formatter = generic
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic
[handler_tabel]
class = opensipkd.base.handlers.SQLAlchemyHandler
args = ()
level = WARN
formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
[alembic_base]
script_location = opensipkd.base:alembic
Instalasi `nginx` dan `uwsgi`
=============================
Install Python Requerement::
Python3
$ sudo apt install -y uwsgi-core uwsgi-plugin-python3 python3-cookiecutter \
python3-pip python3-venv nginx
1. Buat Struktur Directory pada home Folder::
$ su - user
$ mkdir -p wsgi/vassals
$ mkdir logs
$ mkdir tmp
2. Buat `wsgi.py` ::
$ cd wsgi
$ vi wsgi.py
Isi degan script berikut ::
from pyramid.scripts.common import get_config_loader
app_name = 'main'
config_vars = {}
config_uri = '/home/{home}/wsgi/app.ini'
loader = get_config_loader(config_uri)
loader.setup_logging(config_vars)
app = loader.get_wsgi_app(app_name, config_vars)
3. copy template file dari aplikasi menjasi `app.ini` dan edit `app.ini` ::
$cp ../apps/base/test.ini app.ini
$vi app.ini
Tambahkan baris berikut ini::
[uwsgi]
proj = {app_name} #edit disini samakan dengan directory
chdir = /home/{user}/apps/base #edit disini (sesuaikan dengan instalsi)
homedir = /home/{home}
processes = 2
threads = 2
offload-threads = 2
stats = 127.0.0.1:9191
max-requests = 5000
master = True
vacuum = True
enable-threads = true
harakiri = 60
chmod-socket = 020
plugin = python3
pidfile=%(homedir)/tmp/%(proj).pid
socket = %(homedir)/tmp/%(proj).sock
virtualenv = %(homedir)/env
uid = sambara
gid = www-data
# Uncomment `wsgi-file`, `callable`, and `logto` during Part 2 of this tutorial
wsgi-file = %(homedir)/wsgi/wsgi.py
callable = app
4. Buat file emperor.ini::
$ vi emperor.ini
Isi dengan script berikut::
[uwsgi]
proj = sambara
home = /home/{user}
emperor = %(home)/wsgi/vassals
limit-as = 1024
logto = %(home)/logs/emperor.log
uid = {user}
gid = www-data
5. Buat Script Init Pada systemd::
$ vi /etc/systemd/system/{app_name}.uwsgi.service
Isi dengan script berikut ini::
# /lib/systemd/system/emperor.uwsgi.service
[Unit]
Description=uWSGI {AppName} Emperor
After=syslog.target
[Service]
ExecStart=/usr/bin/uwsgi --ini /home/{homedir}/wsgi/emperor.ini
# Requires systemd version 211 or newer
RuntimeDirectory=uwsgi
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target
6. Jalankan dengan systemctl::
$ systemctl start appname.uwsgi.service
A. Kebutuhan
1. Hardware
a. Server Aplikasi
b. Server Citra
2. Software
a. Operating Sytem Debian 8 atau lebih tinggi
b. Web Server Apache 2.0 Atau Nginx Server sebagai proxy
c. WMS (Web Map Service) Geoserver/Map Server
d. Database Postgresql 9.1 atau lebih tinggi
e. Database GIS Postgis 2.0
f. Programming Python 2.7 dengan virtual environment.
B. Setting Aplikasi
1. WMS
2. Aplikasi Base
a. buat user dan database 'aset' contoh
$su - postgres
$psql
psql#create user aset password '4s3t';
psql#create database aset owner aset;
b. sebagai root buat user aplikasi misalnya 'aset'
$add user aset
ikuti langkah-langkah yang tampil di layar
c. buat virtualenvironment
$su - aset
$virtualenv env
d. clone aplikasi base sebagai apps
$git clone http://git.opensipkd.com/solo/base.git apps
e. install aplikasi
$cd apps
$../env/bin/python setup.py develop-use-pip
f. copy file test.ini menjadi live.ini
$cp test.ini live.ini
g. Lakukan perubahan pada file live.ini sesuai dengan kebutuhan
baris :
- sqlalchemy.url
- session.url
- baris modules di remark dulu core, pbb, pbb_simpel
h. jalankan konfigurasi database
$../env/bin/initialize_opensipkd_db live.ini
i. jalankan aplikasi pada folder apps
$../env/bin/pserve live.ini
3. Aplikasi Aset
a. masuk ke folder ~/apps/opensipkd
$cd ~/apps/opensipkd
$git clone http://git.opensipkd.com/solo/aset.git
b. ubah live.ini
- aset.url
- modules = aset
c. inisiasi lagi database
$../env/bin/initialize_opensipkd_db live.ini
d. test jalankan aplikasi pada folder apps
$../env/bin/pserve live.ini
4. Aplikasi Map (aset)
a. masuk ke folder ~/apps/opensipkd
$cd ~/apps/opensipkd
$git clone http://git.opensipkd.com/solo/map.git
$cd map
$git clone http://git.opensipkd.com/solo/map_aset.git aset
b. ubah live.ini
- aset.url
- modules = aset, map, map_aset
c. inisiasi lagi database
$../env/bin/initialize_opensipkd_db live.ini
d. test jalankan aplikasi pada folder apps
$../env/bin/pserve live.ini
\ No newline at end of file
20 JanuaryChange Project Structure
+opensipkd
+--api
+--views
+--models
+--reports
+--tools
+--statics
+--scripts
15-Nov Pemindahan Departemen dan Partner dari Core ke opensipkd
5-november-2018
Penambahan fungsi request._host
2021-06-07 11:50:19,331 INFO [alembic.runtime.migration][MainThread] Context impl PostgresqlImpl.
2021-06-07 11:50:19,332 INFO [alembic.runtime.migration][MainThread] Will assume transactional DDL.
2021-06-07 11:50:19,360 INFO [alembic.runtime.migration][MainThread] Running upgrade -> 35f453a443, alter users date fields with time zone
2021-06-07 11:50:19,419 INFO [alembic.runtime.migration][MainThread] Running upgrade 35f453a443 -> e628a2dc0b23, add users api_key
2021-06-07 11:50:19,436 INFO [alembic.runtime.migration][MainThread] Running upgrade e628a2dc0b23 -> c35162ddf851, add app_id to route
2021-06-07 11:50:19,436 INFO [alembic.runtime.migration][MainThread] Running upgrade c35162ddf851 -> da566162d3fb, add_route_creted
2021-06-07 11:50:19,436 INFO [alembic.runtime.migration][MainThread] Running upgrade da566162d3fb -> 8ad1f7810384, add_route_updated
2021-06-07 11:50:19,452 INFO [alembic.runtime.migration][MainThread] Running upgrade 8ad1f7810384 -> 23f0ecac4377, add_route_type
2021-06-07 11:50:19,468 INFO [alembic.runtime.migration][MainThread] Running upgrade 23f0ecac4377 -> 72dd62d47460, change_route_status_null
2021-06-07 11:56:16,629 INFO [waitress][MainThread] Serving on http://0.0.0.0:6552
2021-06-07 11:56:39,110 INFO [opensipkd.base.views][waitress-0] []
2021-06-07 11:56:40,136 WARNI [waitress.queue][MainThread] Task queue depth is 1
2021-06-07 11:56:40,136 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:56:40,614 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:56:40,618 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:56:40,628 WARNI [waitress.queue][MainThread] Task queue depth is 1
2021-06-07 11:56:40,634 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:56:40,638 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:56:40,645 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:56:40,651 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:56:40,659 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:56:40,664 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:56:40,675 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:56:40,685 WARNI [waitress.queue][MainThread] Task queue depth is 1
2021-06-07 11:56:40,686 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:56:40,692 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:56:40,701 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:56:40,708 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:56:40,714 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:56:40,720 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:56:40,726 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:56:40,901 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:56:40,915 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:56:40,941 WARNI [waitress.queue][MainThread] Task queue depth is 1
2021-06-07 11:56:40,943 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:56:52,315 WARNI [waitress.queue][MainThread] Task queue depth is 1
2021-06-07 11:56:55,682 WARNI [opensipkd.base.views.login_user][waitress-2] User admin at Addr 127.0.0.1: Login Sukses
2021-06-07 11:56:55,856 INFO [opensipkd.base.views][waitress-3] ['Sukses Login']
2021-06-07 11:56:55,926 WARNI [waitress.queue][MainThread] Task queue depth is 1
2021-06-07 11:56:55,927 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:57:04,806 WARNI [waitress.queue][MainThread] Task queue depth is 1
2021-06-07 11:57:04,814 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:57:04,829 WARNI [waitress.queue][MainThread] Task queue depth is 1
2021-06-07 11:57:04,853 WARNI [waitress.queue][MainThread] Task queue depth is 1
2021-06-07 11:57:04,855 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:57:04,887 WARNI [waitress.queue][MainThread] Task queue depth is 1
2021-06-07 11:57:04,892 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:57:04,916 WARNI [waitress.queue][MainThread] Task queue depth is 1
2021-06-07 11:57:04,966 WARNI [waitress.queue][MainThread] Task queue depth is 1
2021-06-07 11:57:04,967 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:57:48,414 INFO [opensipkd.base.views][waitress-3] []
2021-06-07 11:57:48,500 WARNI [waitress.queue][MainThread] Task queue depth is 1
2021-06-07 11:57:48,504 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:57:53,048 INFO [opensipkd.base.views][waitress-2] []
2021-06-07 11:57:53,113 WARNI [waitress.queue][MainThread] Task queue depth is 1
2021-06-07 11:57:53,117 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:57:53,169 WARNI [waitress.queue][MainThread] Task queue depth is 1
2021-06-07 11:57:53,169 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 11:57:53,196 WARNI [waitress.queue][MainThread] Task queue depth is 1
2021-06-07 11:57:53,259 WARNI [waitress.queue][MainThread] Task queue depth is 1
2021-06-07 11:57:53,288 WARNI [waitress.queue][MainThread] Task queue depth is 1
2021-06-07 11:57:53,321 WARNI [waitress.queue][MainThread] Task queue depth is 1
2021-06-07 11:57:53,322 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-06-07 12:01:05,878 INFO [opensipkd.base][waitress-3] ORDERING
2021-06-07 12:01:17,115 INFO [opensipkd.base.views][waitress-0] []
2021-06-07 12:01:20,840 INFO [opensipkd.base.views][waitress-2] []
2021-06-07 12:01:20,904 WARNI [waitress.queue][MainThread] Task queue depth is 1
2021-06-07 12:01:20,915 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-08-11 12:10:38,627 INFO [alembic.runtime.migration][MainThread] Context impl PostgresqlImpl.
2021-08-11 12:10:38,627 INFO [alembic.runtime.migration][MainThread] Will assume transactional DDL.
2021-08-11 12:10:38,721 INFO [alembic.runtime.migration][MainThread] Running upgrade -> 35f453a443, alter users date fields with time zone
2021-08-11 12:10:38,824 INFO [alembic.runtime.migration][MainThread] Running upgrade 35f453a443 -> e628a2dc0b23, add users api_key
2021-08-11 12:10:38,864 INFO [alembic.runtime.migration][MainThread] Running upgrade e628a2dc0b23 -> c35162ddf851, add app_id to route
2021-08-11 12:10:38,871 INFO [alembic.runtime.migration][MainThread] Running upgrade c35162ddf851 -> da566162d3fb, add_route_creted
2021-08-11 12:10:38,876 INFO [alembic.runtime.migration][MainThread] Running upgrade da566162d3fb -> 8ad1f7810384, add_route_updated
2021-08-11 12:10:38,887 INFO [alembic.runtime.migration][MainThread] Running upgrade 8ad1f7810384 -> 23f0ecac4377, add_route_type
2021-08-11 12:10:38,897 INFO [alembic.runtime.migration][MainThread] Running upgrade 23f0ecac4377 -> 72dd62d47460, change_route_status_null
2021-08-11 12:16:02,832 INFO [waitress][MainThread] Serving on http://0.0.0.0:6552
2021-08-11 12:16:50,779 INFO [waitress][MainThread] Serving on http://0.0.0.0:6543
2021-08-11 12:16:57,605 INFO [opensipkd.base.views][waitress-0] []
2021-08-11 12:17:12,406 WARNI [opensipkd.base.views.login_user][waitress-3] User admin at Addr 127.0.0.1: Login Sukses
2021-08-11 12:17:12,650 INFO [opensipkd.base.views][waitress-1] ['Sukses Login']
2021-08-11 12:17:12,733 WARNI [waitress.queue][MainThread] Task queue depth is 1
2021-08-11 12:17:12,739 WARNI [waitress.queue][MainThread] Task queue depth is 2
2021-09-12 23:00:09,539 INFO [alembic.runtime.migration][MainThread] Context impl PostgresqlImpl.
2021-09-12 23:00:09,540 INFO [alembic.runtime.migration][MainThread] Will assume transactional DDL.
2021-09-12 23:00:09,553 INFO [alembic.runtime.migration][MainThread] Running upgrade -> 35f453a443, alter users date fields with time zone
2021-09-12 23:00:09,610 INFO [alembic.runtime.migration][MainThread] Running upgrade 35f453a443 -> e628a2dc0b23, add users api_key
2021-09-12 23:00:09,635 INFO [alembic.runtime.migration][MainThread] Running upgrade e628a2dc0b23 -> c35162ddf851, add app_id to route
2021-09-12 23:00:09,640 INFO [alembic.runtime.migration][MainThread] Running upgrade c35162ddf851 -> da566162d3fb, add_route_creted
2021-09-12 23:00:09,646 INFO [alembic.runtime.migration][MainThread] Running upgrade da566162d3fb -> 8ad1f7810384, add_route_updated
2021-09-12 23:00:09,658 INFO [alembic.runtime.migration][MainThread] Running upgrade 8ad1f7810384 -> 23f0ecac4377, add_route_type
2021-09-12 23:00:09,668 INFO [alembic.runtime.migration][MainThread] Running upgrade 23f0ecac4377 -> 72dd62d47460, change_route_status_null
2021-09-12 23:10:35,031 INFO [waitress][MainThread] Serving on http://0.0.0.0:6552
2021-09-12 23:11:03,397 INFO [waitress][MainThread] Serving on http://0.0.0.0:6543
2021-09-12 23:12:06,309 INFO [waitress][MainThread] Serving on http://0.0.0.0:6543
2021-09-12 23:12:31,460 INFO [opensipkd.base.views][waitress-0] []
2021-09-12 23:17:18,175 INFO [waitress][MainThread] Serving on http://0.0.0.0:6543
2021-09-12 23:20:14,478 INFO [waitress][MainThread] Serving on http://0.0.0.0:6543
2021-09-12 23:20:53,096 INFO [waitress][MainThread] Serving on http://0.0.0.0:6543
2021-09-12 23:21:58,577 INFO [waitress][MainThread] Serving on http://0.0.0.0:6543
[build-system]
requires = ['setuptools >= 64']
[project]
name = 'opensipkd-base'
version = '4.2'
dependencies = [
'sqlalchemy',
'colander',
'pyramid',
'pyramid_tm',
"pyramid_beaker",
"pyramid_mailer",
'SQLAlchemy',
'transaction',
'waitress',
'pyramid_beaker',
'pyramid_mailer',
'ziggurat-foundations',
'zope.sqlalchemy',
'pytz',
'deform',
'psycopg2-binary',
'pyramid_chameleon',
'pyramid_rpc',
'requests',
'sqlalchemy-datatables',
'py3o.template',
'wheezy.captcha',
'icecream',
'google-api-python-client',
'google',
'pyjwt',
]
requires-python = '>= 3.9'
authors = [
{name='Agus Gustiana', email='aa.gustiana@gmail.com'},
]
description = 'Basis Aplikasi openSIPKD'
readme = 'README.rst'
license = {text='Apache Software License'}
classifiers = [
'Programming Language :: Python :: 3',
'Operating System :: OS Independent',
'Framework :: Pylons',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: WSGI :: Application',
]
[project.entry-points."paste.app_factory"]
main = 'opensipkd.base:main'
[project.scripts]
initialize_opensipkd_db = 'opensipkd.base.scripts.initializedb:main'
import_log = 'opensipkd.base.scripts.import_log:main'
https://linuxconfig.org/how-to-change-from-default-to-alternative-python-version-on-debian-linux
update-alternatives --list python
if error:
update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
update-alternatives --install /usr/bin/python python /usr/bin/python2.5 2
selection
update-alternatives --config python
NGINX
apt-get install python-dev python-pip nginx
sudo apt-get update
sudo apt-get install python-dev python-pip nginx
1. Create env jika belum ada
install uwsgi
../env/bin/pip install uwsgi
pip install uwsgi
pip install PasteScript
1. Create WSGI File::
nano ~/myapp/wsgi.py
def application(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])
return ["<h1 style='color:blue'>Hello There!</h1>"]
uwsgi --socket 0.0.0.0:8080 --protocol=http -w wsgi
2. Edit Ini File::
nano ~/myapp/myapp.ini
[uwsgi]
module = wsgi:application
master = true
processes = 5
socket = myapp.sock
chmod-socket = 664
vacuum = true
die-on-term = true
3. Create an Upstart File to Manage the App::
sudo nano /etc/init/myapp.conf
description "uWSGI instance to serve myapp"
start on runlevel [2345]
stop on runlevel [!2345]
setuid demo
setgid www-data
script
cd /home/demo/myapp
. myappenv/bin/activate
uwsgi --ini myapp.ini
end script
sudo start myapp
ps aux | grep myapp
sudo stop myapp
3. Configure NGINX::
Edit Config File
sudo nano /etc/nginx/sites-available/myapp
server {
listen 80;
server_name server_domain_or_IP;
location / {
include uwsgi_params;
uwsgi_pass unix:/home/demo/myapp/myapp.sock;
}
}
sudo service nginx configtest
sudo service nginx restart
uwsgi --paste config:/opt/env/wiki/development.ini --socket :3031 -H /opt/env
Cara lain
https://docs.pylonsproject.org/projects/pyramid-cookbook/en/latest/deployment/uwsgi_nginx_systemd.html
/etc/systemd/system/pyramid.service
[Unit]
Description=pyramid app
# Requirements
Requires=network.target
# Dependency ordering
After=network.target
[Service]
TimeoutStartSec=0
RestartSec=10
Restart=always
# path to app
WorkingDirectory=/opt/env/wiki
# the user that you want to run app by
User=app
KillSignal=SIGQUIT
Type=notify
NotifyAccess=all
# Main process
ExecStart=/opt/env/bin/uwsgi --ini-paste-logged /opt/env/wiki/development.ini
[Install]
WantedBy=multi-user.target
https://docs.pylonsproject.org/projects/pyramid-cookbook/en/latest/deployment/uwsgi_nginx_systemd.html
NGINX
location / {
proxy_set_header Host $http_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;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 60s;
proxy_send_timeout 90s;
proxy_read_timeout 90s;
proxy_buffering off;
proxy_temp_file_write_size 64k;
proxy_pass http://pyramid;
proxy_redirect off;
}
transaction
pyramid
SQLAlchemy
setuptools
pyreportjasper
colander
deform
iso8601
python-dateutil
google
alembic
pytz
translationstring
icecream
\ No newline at end of file
pyramid
pyramid_tm
SQLAlchemy
transaction
zope.sqlalchemy
waitress
pyramid_beaker
pyramid_rpc
pyramid_mailer
pyramid_xmlrpc
ziggurat-foundations
colander
deform>=2.0a2
pyramid_chameleon
psycopg2-binary
alembic>=0.3.4
pytz
sqlalchemy-datatables
py3o.template
wheezy.captcha
google-api-python-client
google
pyramid_debugtoolbar
\ No newline at end of file
File mode changed
import os
import setuptools
from setuptools import setup, find_packages
here = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(here, 'README.md')) as f:
README = f.read()
with open(os.path.join(here, 'CHANGES.txt')) as f:
CHANGES = f.read()
line = CHANGES.splitlines()[0]
version = line.split()[0]
requires = [
'sqlalchemy',
'wheel',
'colander',
'pyramid',
'pyramid_tm',
"pyramid_beaker",
"pyramid_mailer",
'SQLAlchemy',
'transaction',
'waitress',
'pyramid_beaker',
'pyramid_mailer',
'ziggurat-foundations',
'zope.sqlalchemy',
'pytz',
'deform',
'psycopg2-binary',
'pyramid_chameleon',
'pyramid_rpc',
'requests',
'sqlalchemy-datatables',
'py3o.template',
'wheezy.captcha',
'icecream',
'google-api-python-client',
'google',
'pyjwt',
# 'z3c.rml',
# 'opensipkd-tools @git+https://git.opensipkd.com/aa.gusti/opensipkd-tools.git',
]
dev_requires = [
'pyramid_debugtoolbar',
'pytest',
]
setup(
name='opensipkd_base',
version=version,
description='Basis Aplikasi openSIPKD',
long_description=README + '\n\n' + CHANGES,
author='Agus Gustiana',
author_email='aa.gustiana@gmail.com',
classifiers=[
"Programming Language :: Python",
"Framework :: Pylons",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
],
license='Apache Software License',
keywords='web pyramid pylons base',
packages=find_packages(),
zip_safe=False,
install_requires=requires,
tests_require=requires,
extras_require={
'dev': dev_requires,
},
package_data={'opensipkd': [
'base/views/templates/*.pt',
'base/static/*.*',
'base/reports/*.*',
'base/alembic/*.*',
'base/alembic/versions/*.*',
'base/views/*.tpl',
'base/locale/*.*',
], },
data_files=[('etc', ['etc/live_opensipkd.tpl',
'etc/test_opensipkd.tpl', ])],
setuptools.setup(
packages=setuptools.find_packages(),
include_package_data=True,
entry_points="""\
[paste.app_factory]
main = opensipkd.base:main
[console_scripts]
initialize_opensipkd_db = opensipkd.base.scripts.initializedb:main
import_log = opensipkd.base.scripts.import_log:main
""",
)
)
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!