#alias
alias ionic-build="docker run -ti --privileged -v /share/ionic/tabs/tabs:/myApp:rw -p 8103:8100 -p 35728:35729 mkaag/ionic bash"
alias ionic-build="docker run -ti --privileged -v /share/ionic/tabs/tabs:/myApp:rw -p 8103:8100 -p 35728:35729 ionic-build bash"
alias cnpm="npm --registry=https://registry.npm.taobao.org \
--cache=$HOME/.npm/.cache/cnpm \
--disturl=https://npm.taobao.org/dist \
--userconfig=$HOME/.cnpmrc"
echo 'alias cnpm="npm --registry=https://registry.npm.taobao.org --cache=$HOME/.npm/.cache/cnpm --disturl=https://npm.taobao.org/dist --userconfig=$HOME/.cnpmrc"' >> ~/.zshrc && source ~/.zshrc
NPM代理配置
如果您工作的环境中有防火墙,那么可能需要为npm配置代理。在命令行模式下,运行下面命令:
配置http代理: npm config set proxy [proxy]:[port].
配置https代理: npm config set https-proxy [proxy]:[port].
例如,下面为http和https设置了相同的代理http://example.proxy.com和代理端口8080。
> npm config set proxy http://example.proxy.com:8080
> npm config set https-proxy http://example.proxy.com:8080
#确定操作系统
cat /etc/issue
lsb_release -a
#加速源
npm install -g cnpm --registry=https://registry.npm.taobao.org
sed -i 's|archive.ubuntu.com|mirrors.aliyun.com|g' /etc/apt/sources.list
sed -i 's|httpredir.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list
sed -i 's|security.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list
https://q9h4ikji.mirror.aliyuncs.com
sudo sed -i 's|OPTIONS='--registry-mirror=true'|OPTIONS='--registry-mirror=https://q9h4ikji.mirror.aliyuncs.com|g' /etc/sysconfig/docker && service docker restart
sudo sed -i 's|other_args=""|other_args="--registry-mirror=https://q9h4ikji.mirror.aliyuncs.com"|g' /etc/sysconfig/docker && service docker restart
docker-machine ssh default "echo 'EXTRA_ARGS=\"--registry-mirror=https://q9h4ikji.mirror.aliyuncs.com\"' | sudo tee -a /var/lib/boot2docker/profile"
docker-machine restart default
docker-machine ssh default 'mkdir linker && sudo mount -t vboxsf linker linker'
# TODO: remove when https://github.com/npm/npm/issues/9863 is fixed
RUN cd $(npm root -g)/npm \
&& npm install fs-extra \
&& sed -i -e s/graceful-fs/fs-extra/ -e s/fs\.rename/fs.move/ ./lib/utils/rename.js
#Android apk Builder
Set the JAVA_HOME environment variable to the location of your JDK installation
Set the ANDROID_HOME environment variable to the location of your Android SDK installation
It is also recommended that you add the Android SDK's tools and platform-tools directories to your PATH
export ANDROID_HOME='/share/docker/android-sdk-linux'
export PATH=$PATH:/share/docker/jdk1.8.0_101/bin/
platforms/android/cordova/lib/builders/GradleBuilder.js
CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL
export CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL="file:/share/docker/gradle-2.13-all.zip"
android list sdk --all --extended
#docker
pkill -f "manage.py runserver"
python manage.py runserver 0.0.0.0:8000
docker run --name nginx -it -v /share/ionic/tabs/tabs:/etc/nginx -p 80:80 nginx bash
service nginx restart
api请求要带最后一个斜杠
http://192.168.99.100/i/menuglobals/
#cordova plugins
cordova plugin remove cordova-plugin-whitelist
cordova plugin add cordova-plugin-whitelist
ionic browser add crosswalk
ionic serve --platform="android"
cordova plugin remove cn-linker-cordova
cordova plugin add cordovaLinker
ionic run android --device s -cls
#python permission
IsOwnerOrReadOnly未使用
import django
print (django.__path__)
#调试
weinre --boundHost 192.168.31.125
weinre --boundHost 192.168.31.125 --httpPort 8081
#自动挂载(有问题)
若想开机自动挂载,可以在 /etc/fstab 文件末添加一项
sharing /mnt/share vboxsf defaults 0 0
或
sharing /mnt/share vboxsf rw,gid=100,uid=1000,auto 0 0
当然,这个还不行的,还记得刚开始分配数据空间那个地方吗,那里也有一个自动挂载的选项,是VxBox提供的。
但是,如果那个选项勾选了,那么这个共享这辈子也不会开机自动挂载,即便是设置了 /etc/fstab文件,要想实现自动挂载,VxBox的那个自动挂载的选项不能选,而且要配置/etc/fstab文件!
大部分网络资料都是说在 /etc/fstab 文件中追加
VirtualBox虚拟机文件夹共享挂载命令 “ sharing /mnt/share vboxsf defaults 0 0 ”,其实是错误的,
因为系统调用fstab的时候,Virtualbox的共享目录的模块还没有加载,所以每次加载都会失败,最终的解决方案如下:
在文件 /etc/rc.local 中(用root用户)追加如下命令
mount -t vboxsf sharing /mnt/share
#Genymotion
关闭硬件声音
设置网卡2为桥接,运行后确认网卡2是否成功启用
安装Genymotion-ARM-Translation_v1.1
#server-build
cd E:\Projects\IM\sealtalk-server
grunt build --force
#server-run
cd E:\Projects\IM\sealtalk-server
set DEBUG=*
grunt nodemon
#debug
set DEBUG=*,-not_this
ls env:
$env:DEBUG="*"
#web-connect
cd E:\Projects\IM\sealtalk-web
grunt build
grunt connect
#cors
注释$httpProvider.defaults.withCredentials = true;
app.use cors # 使用 CORS,支持跨域
origin: Config.CORS_HOSTS
credentials: true
改为
app.use cors # 使用 CORS,支持跨域
origin: '*'
# credentials: true
https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Access_control_CORS#Requests_with_credentials
多个站点跨域请求
# app.use cors # 使用 CORS,支持跨域
# origin: Config.CORS_HOSTS
# credentials: true
whitelist = Config.CORS_HOSTS # ['http://192.168.31.125:8100','http://192.168.31.125:81']
corsOptions=
origin: (origin,callback) ->
originIsWhitelisted = whitelist.indexOf origin != -1
callback(null,originIsWhitelisted)
credentials: true
app.use cors corsOptions
#ionic-serve
cd G:\share\ionic\tabs\tabs
ionic serve
#重启
关闭80端口
1、挂载
sudo mkdir /docker && sudo mount -t vboxsf docker /docker
sudo mkdir /share && sudo mount -t vboxsf share /share
docker start db1
docker start appsrv
docker start nginx
docker start imdb
2、启动
docker exec -it db1 bash
service mysql start
docker exec -it nginx bash
service nginx start
docker exec -it appsrv bash
cd ../app/trunk/
python manage.py runserver 0.0.0.0:8000
3、应用ls /
--sealtalk-server
grunt nodemon
--sealtalk-web
grunt connect
4、socorro
docker run --privileged -d -ti -e "container=docker" -v /sys/fs/cgroup:/sys/fs/cgroup --name socorro socorro /usr/sbin/init
#更改服务器ip
1、Nginx中地址转向
2、应用服务器数据库地址
sed -i 's|192.168.31.125|192.168.2.125|g' /app/trunk/Linker/settings.py
3、应用服务器svn服务器地址
svn relocate https://192.168.31.125:8443/svn/linkersrv https://192.168.2.125:8443/svn/linkersrv
#部署到华为云
1、应用服务器
cd /linker
svn checkout https://112.91.82.75:8443/svn/linkersrv/trunk
mv trunk srv
1.1、数据库服务器
docker run -p 3307:3306 -v ~/linker/sysdb/data:/var/lib/mysql --name sysdb -e MYSQL_ROOT_PASSWORD=abc.123 -d mysql
2、IM服务器
docker pull node
npm install
2.1、IM数据库服务器
chmod 777 linker/imsrv/data
docker run -p 3305:3306 -v ~/linker/imsrv/data:/var/lib/mysql --name imdb -e MYSQL_ROOT_PASSWORD=abc.123 -d mysql
2.2、启动IM应用服务器
docker run -it -p 8585:8585 --name imsrv -d --link imdb:imdb -v ~/linker/imsrv/:/usr/src/imsrv -w /usr/src/imsrv imsrv node build/src
3、nginx
docker run --name nginx -v ~/linker/nginx:/etc/nginx -p 80:80 -d nginx
环境变量
export NODE_ENV=production;node build/src/
#测试环境搭建
挂载
cd ~
mkdir linker
sudo mount -t vboxsf linker linker
数据库表情支持
docker run --name mysql_mb4 -it mysql bash
cat </etc/mysql/my.cnf
# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
EOT
docker commit mysql_mb4 mysql:mb4
1、应用服务器
1.1、数据库 sysdb
docker run -p 3307:3306 -v ~/linker/data/sysdb:/var/lib/mysql --name sysdb -e MYSQL_ROOT_PASSWORD=abc.123 -d mysql:mb4
1.2、数据库 dbsrv1
docker run -p 3308:3306 -v ~/linker/data/dbsrv1:/var/lib/mysql --name dbsrv1 -e MYSQL_ROOT_PASSWORD=abc.123 -d mysql:mb4
1.3、搭建srv (DJAGNO)
1.3.1、安装中间件
docker run -p 8000:8000 -v ~/linker/srv:/linker/srv -w /linker/srv --link sysdb:sysdb --link dbsrv1:dbsrv1 --name srv -it srv:1.10.1 bash
pip install djangorestframework
pip install pymysql
pip install django-cors-headers
pip install qiniu
1.3.2、初始化数据库
运行创建基础表的sql语句(dbmodel/linkersys.sql)
python manage.py migrate
1.3.3、提交更改
docker commit srv srv:1.10.1
1.4、启动
docker run --rm -p 8000:8000 -v ~/linker/srv:/linker/srv -w /linker/srv --link sysdb:sysdb --link dbsrv1:dbsrv1 --name srv -it srv:1.10.1 python manage.py runserver 0.0.0.0:8000 --settings=Linker.settingsproduction
2、IM服务器
2.1、数据库imdb
docker run -p 3305:3306 -v ~/linker/data/imdb:/var/lib/mysql --name imdb -e MYSQL_ROOT_PASSWORD=abc.123 -d mysql:mb4
2.2、imsrv
docker pull node:4.6.2-slim
2.2.1、初始化数据库
docker run --rm --name imsrv -it -p 8585:8585 --link imdb:imdb -v ~/linker:/linker -w /linker/imsrv/ node:4.6.2-slim bash
npm install
npm install --save-dev coffee-script
npm run initdb
2.2.2、启动imsrv
docker run --name imsrv -it -p 8585:8585 --link imdb:imdb -v ~/linker:/linker -w /linker/imsrv/ -d node:4.6.2-slim node /linker/imsrv/build/src/index.js
export NODE_ENV=production;node build/src/
3、NGINX服务器
docker run --name nginx -v ~/linker/nginx:/etc/nginx -p 80:80 -d nginx
移除所有容器 docker rm -f $(docker ps -a| awk '{print $1}')
开机记录 last
重启 shutdown -r now
#弹性云
禁用防火墙,添加入站规则
service iptables stop #停止
chkconfig iptables off #禁用
1、安装docker
https://docs.docker.com/engine/installation/linux/centos/
sudo yum update
curl -fsSL https://get.docker.com/ | sh
service start docker
#android debug
Hi, I've just documented how to view the console log on android:
Running logcat (see webview console log messages) on android
run ADB and get connected devices (first change dir to the android platform tools dir)
$ cd /Users/kevin/ADT/sdk/platform-tools
$ adb devices
List of devices attached
40CBA8038654 device
get PID (process ID) of app - first get all processes
$ adb -s 40CBA8038654 shell ps
then grep that (look for a string that identifies your app)
$ adb -s 40CBA8038654 shell ps | grep solomon (solomon being part of package name)
u0_a129 17099 151 363464 69256 ffffffff 00000000 S ie.solomon.myapp
$ adb -s 40CBA8038654 shell ps | grep 17099 (check for sub processes - so far i've found that the app runs as a single process)
u0_a129 17099 151 363464 69256 ffffffff 00000000 S ie.solomon.myapp
finally run logcat and filter by PID so you just see output from your app:
adb -s 40CBA8038654 shell logcat –v time | grep 17099
For IOS, I've found that once you have installed it via the USB, by doing cordova run ios, it will automatically provide a log
All this is on a Mac, but steps exactly same on Ubuntu (Linux). Of course IOS only works with a Mac
监控adb安装应用
https://gonzalo123.com/2014/07/21/testing-phonegapcordova-applications-fast-as-hell-in-the-device-with-ionic-framework/
#Testing Phonegap/Cordova applications fast as hell in the device (with ionic framework)
cordova run android --device
cd www
cmd /c mklink cordova.js ..\..\platforms\android\assets\www\cordova.js
cmd /c mklink cordova_plugins.js ..\..\platforms\android\assets\www\cordova_plugins.js
cmd /c mklink /D plugins ..\..\platforms\android\assets\www\plugins
cd www
rm www/cordova.js
rm www/cordova_plugins.js
rd www/plugins
ionic serve --nobrowser
ionic serve -b
#贡献代码
Fork
创建您的特性分支 git checkout -b my-new-feature
提交您的改动 git commit -am 'Added some feature'
将您的修改记录提交到远程 git 仓库 git push origin my-new-feature
然后到 github 网站的该 git 远程仓库的 my-new-feature 分支下发起 Pull Request
#django
动态设置http://stackoverflow.com/questions/6528723/changing-django-settings-at-runtime
django部署,部署是一个大事,为了部署django相信你应该会学习fabric,supervisor,gunicorn|uwsgi(gunicorn胜在配置简单,uwsgi有很多分析是内存占用小,速度快)
相信很多时候你会需要跑一些统计或者其他的定时任务,django-celery也是需要学的,当然你可以用linux的crontab,这个看你(celery有很多不错的配置)
from django.core import management
management.call_command('syncdb', interactive=False)
pip freeze > requirements.txt
pip install -r requirements.txt
#二维码登录
https://github.com/mdp/rotp
https://galois.com/blog/2011/01/quick-authentication-using-mobile-devices-and-qr-codes/
http://blog.miguelgrinberg.com/post/two-factor-authentication-with-flask
#Windows server 2012R2上无法安装Intel I219-V网卡驱动的问题
http://blog.csdn.net/ryu2003/article/details/50855146
# Crosswalk
cnpm install -g crosswalk-app-tools
crosswalk-app check android
#git proxy
set https_proxy="https://127.0.0.1:1080/"
#boot2docker自动挂载
"C:/Program Files/Oracle VM VirtualBox/VBoxManage" sharedfolder add default -name linker -hostpath /f/linker
#Then make this folder automount
docker-machine ssh
sudo vi /var/lib/boot2docker/profile
Add following at the end of profile file:
sudo mkdir /home/docker/linker
sudo mount -t vboxsf linker /home/docker/linker
Restart docker-machine
docker-machine restart
#cat追加文件内容
cat >>profile < TZ='Asia/Shanghai'; export TZ
> EOF
# 更改时区
dpkg-reconfigure tzdata
# mysql 重置自增长id的初始值
alter table SchemaInfo auto_increment = 5