-
Notifications
You must be signed in to change notification settings - Fork 0
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
サーバーに設定する #21
Comments
uWSGI を使おうかと思ってたんだが、 Trac 用に既に入れててそっちは Python2 。 conflict してややこしいことになる悪寒(´・_・`) そこは気をつけないと… |
pipenv とか使ったほうがいいのかなぁ…(´・_・`) |
poetry の存在とかすっかり忘れてたけどアプリケーションの環境固定用であれば pipenv が一番お手頃かつ十分な気がしたので pipenv で環境作ってみた。 実際動かすには murachi@maha:~/github/tmpbox$ sudo pipenv sync
murachi@maha:~/github/tmpbox$ cd src
murachi@maha:~/github/tmpbox/src$ sudo pipenv shell
(tmpbox) root@maha:~/github/tmpbox/src# uwsgi --http=0.0.0.0:6543 --wsgi-file=tmpbox.py --callable=app --uid=tmpbox |
uWSGI 用の設定ファイルも setup.py にて生成するようにしてみた。 pipenv からだと UID を指定してのデバッグ実行が murachi@maha:~/github/tmpbox$ cd src
murachi@maha:~/github/tmpbox/src$ sudo su tmpbox -c ./run.sh pipenv を用いる場合は以下の方法でデバッグ実行できるようになる。 murachi@maha:~/github/tmpbox$ sudo pipenv run uwsgi --ini src/conf.d/uwsgi-debug.ini |
一旦 merge しまっす。 |
えー。鯖設定を行っているのですが、 setup.py 実行中に MySQL への SQL 発行でコケました orz
|
なるほどなるほど。
どこかしらのライブラリベンダーにいちゃもんつけて修正してもらいたいレベルの案件ですが、しゃーないので回避策を探るしかなさそう… orz |
嘘やったorz MariaDB [minimum]> create table hoge (
-> hoge_id int not null primary key
-> , create_date date not null default current_date
-> );
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'current_date
)' at line 3
MariaDB [minimum]> create table hoge (
-> hoge_id int not null primary key
-> , create_date date not null default current_date()
-> );
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'current_date()
)' at line 3
MariaDB [minimum]> |
もともと出ていたエラーの原因は MariaDB のバージョンが古いことでした ( で、MariaDB のバージョンを上げてリトライしたところ、今度はまた別のエラーが…(´・_・`)
|
色々とバグ修正。で、デバッグモードで動かせるようになったが、ログインした時点で以下のエラーが発生…。
|
uWSGI のデバッグモードでファイルのアップロードまで動くのを確認。 |
残作業:
|
|
訳がわからない。いや、分かりかけてきてはいるんだけど、再現性が安定しない。 root@ik1-314-17353:~# ls -la /var/tmpbox/run/
total 8
drwxr-s--- 2 www-data www-data 4096 5月 14 11:18 .
drwxr-s--- 6 www-data www-data 4096 5月 13 16:46 ..
root@ik1-314-17353:~# systemctl start tmpbox.service
root@ik1-314-17353:~# ls -la /var/tmpbox/run/
total 12
drwxr-s--- 2 www-data www-data 4096 5月 14 11:18 .
drwxr-s--- 6 www-data www-data 4096 5月 13 16:46 ..
-rw-rw-rw- 1 root www-data 6 5月 14 11:18 uwsgi-tmpbox.pid
srw-rw-rw- 1 www-data www-data 0 5月 14 11:18 uwsgi-tmpbox.sock
root@ik1-314-17353:~# systemctl stop tmpbox.service
root@ik1-314-17353:~# ls -la /var/tmpbox/run/
total 12
drwxr-s--- 2 www-data www-data 4096 5月 14 11:18 .
drwxr-s--- 6 www-data www-data 4096 5月 13 16:46 ..
-rw-rw-rw- 1 root www-data 6 5月 14 11:18 uwsgi-tmpbox.pid
root@ik1-314-17353:~# systemctl start tmpbox.service
root@ik1-314-17353:~# ls -la /var/tmpbox/run/
total 12
drwxr-s--- 2 www-data www-data 4096 5月 14 11:19 .
drwxr-s--- 6 www-data www-data 4096 5月 13 16:46 ..
-rw-rw-rw- 1 root www-data 6 5月 14 11:19 uwsgi-tmpbox.pid
srw-rw-rw- 1 www-data www-data 0 5月 14 11:19 uwsgi-tmpbox.sock
root@ik1-314-17353:~# systemctl stop tmpbox.service
root@ik1-314-17353:~# ls -la /var/tmpbox/run/
total 12
drwxr-s--- 2 www-data www-data 4096 5月 14 11:19 .
drwxr-s--- 6 www-data www-data 4096 5月 13 16:46 ..
-rw-rw-rw- 1 root www-data 6 5月 14 11:19 uwsgi-tmpbox.pid
root@ik1-314-17353:~# systemctl start tmpbox.service
root@ik1-314-17353:~# ls -la /var/tmpbox/run/
total 12
drwxr-s--- 2 www-data www-data 4096 5月 14 11:20 .
drwxr-s--- 6 www-data www-data 4096 5月 13 16:46 ..
-rw-rw-rw- 1 root www-data 6 5月 14 11:20 uwsgi-tmpbox.pid
root@ik1-314-17353:~#
|
root@ik1-314-17353:~# systemctl reload tmpbox.service
root@ik1-314-17353:~# tail -n 20 /var/tmpbox/log/uwsgi-tmpbox.log
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /var/tmpbox/run/uwsgi-tmpbox.sock fd 6
Python version: 2.7.12 (default, Apr 15 2020, 17:07:12) [GCC 5.4.0 20160609]
Python main interpreter initialized at 0x149def0
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 208576 bytes (203 KB) for 4 cores
*** Operational MODE: threaded ***
File "/home/murachi/github/tmpbox/src/tmpbox.py", line 36
SyntaxError: Non-ASCII character '\xe8' in file /home/murachi/github/tmpbox/src/tmpbox.py on line 37, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
failed to parse file /home/murachi/github/tmpbox/src/tmpbox.py
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 24852)
spawned uWSGI worker 1 (pid: 24853, cores: 4)
root@ik1-314-17353:~# Python 2.7.12 …だと… |
systemd の設定ですが、 [Unit]
Description=Tmpbox service on uWSGI
After=network.target
ConditionPathExists=/home/murachi/github/tmpbox
[Service]
WorkingDirectory=/home/murachi/github/tmpbox
ExecStart=/usr/local/bin/pipenv run uwsgi --ini src/conf.d/uwsgi-daemon.ini
ExecReload=/usr/local/bin/pipenv run uwsgi --stop /var/tmpbox/run/uwsgi-tmpbox.pid
ExecStop=/usr/local/bin/pipenv run uwsgi --stop /var/tmpbox/run/uwsgi-tmpbox.pid
Restart=on-failure
Type=forking
[Install]
WantedBy=multi-user.target
systemd から pipenv を使う場合のコツとかがあるのかな…(´・_・`) |
やっと原因わかった。 murachi@ik1-314-17353:~/github/tmpbox$ sudo pipenv run uwsgi --ini src/conf.d/uwsgi-daemon.ini
[sudo] murachi のパスワード:
[uWSGI] getting INI configuration from src/conf.d/uwsgi-daemon.ini
murachi@ik1-314-17353:~/github/tmpbox$ sudo tail -n 20 /var/tmpbox/log/uwsgi-tmpbox.log
setgid() to 33
setuid() to 33
chdir() to /home/murachi/github/tmpbox/src
your processes number limit is 7843
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /var/tmpbox/run/uwsgi-tmpbox.sock fd 6
Python version: 3.8.2 (default, Feb 26 2020, 04:23:39) [GCC 5.4.0 20160609]
Python main interpreter initialized at 0x26f66f0
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 208576 bytes (203 KB) for 4 cores
*** Operational MODE: threaded ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x26f66f0 pid: 25027 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 25027)
spawned uWSGI worker 1 (pid: 25031, cores: 4)
murachi@ik1-314-17353:~/github/tmpbox$ sudo pipenv run uwsgi --stop /var/tmpbox/run/uwsgi-tmpbox.pid
murachi@ik1-314-17353:~/github/tmpbox$ sudo su -
root@ik1-314-17353:~# cd /home/murachi/github/tmpbox/
root@ik1-314-17353:/home/murachi/github/tmpbox# pipenv run uwsgi --ini src/conf.d/uwsgi-daemon.ini
[uWSGI] getting INI configuration from src/conf.d/uwsgi-daemon.ini
root@ik1-314-17353:/home/murachi/github/tmpbox# tail -n 20 /var/tmpbox/log/uwsgi-tmpbox.log
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /var/tmpbox/run/uwsgi-tmpbox.sock fd 6
Python version: 2.7.12 (default, Apr 15 2020, 17:07:12) [GCC 5.4.0 20160609]
Python main interpreter initialized at 0x78d160
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 208576 bytes (203 KB) for 4 cores
*** Operational MODE: threaded ***
File "/home/murachi/github/tmpbox/src/tmpbox.py", line 36
SyntaxError: Non-ASCII character '\xe8' in file /home/murachi/github/tmpbox/src/tmpbox.py on line 37, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
failed to parse file /home/murachi/github/tmpbox/src/tmpbox.py
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 25092)
spawned uWSGI worker 1 (pid: 25093, cores: 4)
root@ik1-314-17353:/home/murachi/github/tmpbox# pipenv run uwsgi --stop /var/tmpbox/run/uwsgi-tmpbox.pid
root@ik1-314-17353:/home/murachi/github/tmpbox# インストールしたユーザー環境から そんなわけで、セットアップ時の手順として、 $ sudo pipenv sync するのは間違いで、実は $ sudo su -
# cd /home/account/path/to/project/
# pipenv sync としないといけなかった、ということっぽい。(未確認) |
root 環境から root@ik1-314-17353:/home/murachi/github/tmpbox# tail -n 30 /var/tmpbox/log/uwsgi-tmpbox.log
!!! no internal routing support, rebuild with pcre support !!!
setgid() to 33
setuid() to 33
chdir() to /home/murachi/github/tmpbox/src
your processes number limit is 7843
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /var/tmpbox/run/uwsgi-tmpbox.sock fd 6
Python version: 3.8.2 (default, Feb 26 2020, 04:23:39) [GCC 5.4.0 20160609]
Python main interpreter initialized at 0x1c6bf20
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 208576 bytes (203 KB) for 4 cores
*** Operational MODE: threaded ***
Traceback (most recent call last):
File "/home/murachi/github/tmpbox/src/tmpbox.py", line 3, in <module>
from flask import Flask, url_for, render_template, redirect, abort, send_file, Markup, request, session
ModuleNotFoundError: No module named 'flask'
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 25973)
spawned uWSGI worker 1 (pid: 25974, cores: 4)
--- no python application found, check your startup logs for errors ---
[pid: 25974|app: -1|req: -1/1] 61.125.220.180 () {44 vars in 694 bytes} [Thu May 14 12:09:01 2020] GET / => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 25974|app: -1|req: -1/2] 61.125.220.180 () {44 vars in 694 bytes} [Thu May 14 12:09:03 2020] GET / => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
root@ik1-314-17353:/home/murachi/github/tmpbox# なんでだ… |
訳がわからない。 root 環境から |
|
環境変数 とりあえずこの環境変数を試してみることにします…。 |
issue #21 - pipenv の仮想環境をプロジェクトディレクトリ内に生成するよう修正。
#22 の作業はこの issue を基にやりましょう…。 |
はらぺこ鯖に設定してみる。上手く動かない部分があればバグ修正する。
The text was updated successfully, but these errors were encountered: