Freebsd supervisord+virtualenv 源碼運行odoo10


各種參考:

https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/001432712108300322c61f256c74803b43bfd65c6f8d0d0000

http://blog.sina.com.cn/s/blog_955289220102ykzv.html

http://www.linuxidc.com/Linux/2012-10/71692.htm

https://blog.laslabs.com/2015/09/installing-odoo-8-from-source-ubuntu/

http://www.jianshu.com/p/40caabd91827

------------------------------------------------

切換shell命令:

#pkg install bash

#chsh -s /usr/local/bin/bash

#logout

更換非root用戶默認的shell,#chsh -s /usr/local/bin/bash yourname

---------------------------------------------------

1、安裝postgresql
版本不一樣可能pg的用戶名會是pgsql或者postgres(以下為postgres),以下用/pgsql/data作為數據庫存放目錄

#pkg search postgresql

 # pkg search postgresql

exim-postgresql-4.89_2         High performance MTA for Unix systems on the Internet
libgda5-postgresql-5.2.4       Provides postgresql access for the libgda5 library
opensmtpd-extras-table-postgresql-201606230001_2 PostgreSQL table support for OpenSMTPD
p5-PostgreSQL-PLPerl-Call-1.006_1 Simple interface for calling SQL functions from PostgreSQL PL/Perl
p5-PostgreSQL-PLPerl-Trace-1.001_1 Simple way to trace execution of Perl statements in PL/Perl
p5-Test-postgresql-0.09_1      Perl extension of postgresql runner for tests
pgtcl-postgresql10-2.0.0_1     TCL extension for accessing a PostgreSQL server (PGTCL-NG)
pgtcl-postgresql92-2.0.0_1     TCL extension for accessing a PostgreSQL server (PGTCL-NG)
pgtcl-postgresql93-2.0.0_1     TCL extension for accessing a PostgreSQL server (PGTCL-NG)
pgtcl-postgresql94-2.0.0_1     TCL extension for accessing a PostgreSQL server (PGTCL-NG)
pgtcl-postgresql95-2.0.0_1     TCL extension for accessing a PostgreSQL server (PGTCL-NG)
pgtcl-postgresql96-2.0.0_1     TCL extension for accessing a PostgreSQL server (PGTCL-NG)
postgresql-jdbc-9.2.1004       The Java JDBC implementation for PostgreSQL



挑一個合適的版本,目前9.6版本是沒問題的
#pkg install postgresql96-server-9.6.6
#echo 'postgresql_enable="YES"' >> /etc/rc.conf
#echo 'postgresql_data="/pgsql/data"' >> /etc/rc.conf
#echo 'postgresql_class="postgres"' >> /etc/rc.conf
#echo 'postgresql_initdb_flags="--encoding=utf-8 --lc-collate=C"' >> /etc/rc.conf
 
#mkdir -p /pgsql/date
#chown -R postgres /pgsql
#chmod -R 777 /pgsql/date

#su postgres
$cd /pgsql/data

$

$ initdb -D /pgsql/data

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "C".
The default database encoding has accordingly been set to "SQL_ASCII".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /server/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /pgsql/data -l logfile start

$su root
#service postgresql restart



安裝並創建odoo10數據庫用戶密碼為123456
#su posgres
$psql postgres
#CREATE user odoo10  WITH PASSWORD '123456' CREATEDB;

Ctrl+d退出



2、配置odoo

以下操作root用戶登錄

創建用戶odoo
adduser

 創建odoo10及log目錄

mkdir /odoo10

mkdir /var/log/odoo10/

mkdir /var/log/supervisord/odoo10/

 

目錄權限

chown -R odoo /odoo10

chmod -R 777 /odoo10

chown -R odoo /var/log/odoo10/

chmod -R 777 /var/log/odoo10/

 

用任意方法將odoo10源碼上傳到/odoo10

cd /odoo10
#創建虛擬環境

virtualenv --no-site-packages venv

#激活虛擬環境

source venv/bin/activate

#安裝odoo的py支持環境
 pip install -r requirements.txt

 

deactivate命令退出虛擬環境 退出虛擬環境
node、wkhtmltopdf安裝
pkg install node npm wkhtmltopdf
npm install -g less
npm install -g less-plugin-clean-css
ln -s /usr/local/bin/lessc /usr/bin/lessc
ln -s /usr/bin/node /usr/bin/node
ln -s /usr/bin/nodejs /usr/bin/node

ln -s /usr/bin/wkhtmltopdf /usr/bin/wkhtmltopdf

 


3.創建運行odoo10的配置文件
 vi /odoo10/odoo10.conf
內容如下:

[options]
; This is the password that allows database operations:
admin_passwd = 123456

db_host = 127.0.0.1
db_port = False
db_user = odoo10
db_password = 123456
addons_path = /server/odoo/odoo10/addons,/server/odoo/odoo10/odoo/addons
;addons_path = /server/odoo/odoo/openerp/addons
xmlrpc_port = 8069
log_level = info
logfile = /var/log/odoo10/odoo-server.log
logrotate = True
View Code

 



4、用python啟動odoo
#進入odoo用戶下用odoo10.conf配置啟動odoo
su odoo
source /odoo10/venv/bin/activate
python /odoo10/odoo-bin -c /odoo10/odoo10.conf

 




運行正常則Ctrl+c 退出,有出錯則根據錯誤進行解決
deactivate命令退出虛擬環境
5、用supervisor管理odoo的開機自動啟動
-----------------------------------------------
安裝bash
pkg install bash
創建bash腳本/odoo10/odoo10.sh
vi /odoo10/odoo10.sh
內容如下:
#!/bin/sh
source /odoo10/venv/bin/activate
python /odoo10/odoo-bin -c /odoo10/odoo10.conf

 

 

 ------------------------------------------------------------------

supervisord 管理odoo10.sh

安裝supervisord

pkg search supervisor
py27-supervisor-3.3.3,1        System for controlling process state under UNIX

pkg install py27-supervisor-3.3.3,1
echo 'supervisord_enable="YES"' >> /etc/rc.conf

根據supervisor配置目錄配置odoo10的supervisord腳本

 

vi /usr/local/etc/supervisord.conf
 [include]后面加入
files = supervisor/conf.d/*.conf
superviord-odoo10.conf
vi /usr/local/etc/supervisor/conf.d/superviord-odoo10.conf

內容如下:

[program:odoo10]
command=/usr/local/bin/bash /odoo10/odoo10.sh
directory=/odoo10/
autostart=true
autorestart=true
startsecs=8
environment=HOME="/odoo10",USER="odoo"
user=odoo
redirect_stderr=true
stdout_logfile=/var/log/supervisord/odoo10/supervisor-odoo10.log
stdout_logfile_maxbytes=500MB
stdout_logfile_backups=50
stdout_capture_maxbytes=1MB
stdout_events_enabled=false
loglevel=warn

 

重啟supervisord服務

 service supervisord restart
 supervisorctl status

 

supervisorctl status odoo10
odoo10                           RUNNING   pid 705, uptime 1:30:39

===啟動不起來的可能==
如果手動命令行下bash odoo10.sh可以啟動,supervisor沒有啟動起來

看日志找不到python命令

exec python找不到 看supervisor提示 not found
把python替換為 絕對路徑,如 /odoo_11c/venv/bin/python3.6

 

祝不報錯,結束!

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM