重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
Sentry 是一个开源的实时错误报告工具,支持 web 前后端、移动应用以及游戏,支持 Python、OC、Java、Go、Node、Django、RoR 等主流编程语言和框架 ,还提供了 GitHub、Slack、Trello 等常见开发工具的集成。
10年积累的成都做网站、网站设计、外贸营销网站建设经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先制作网站后付款的网站建设流程,更有称多免费网站建设让你可以放心的选择与我们合作。
github地址
环境 | 说明 |
---|---|
ubuntu16.04 | ip: 10.211.55.14 |
sudo apt-get -y install postgresql postgresql-contrib
> sudo su
> su - postgres
> psql
输入:
postgres =# \password #修改当前用户密码
Enter new password:
Enter it again:
postgres =# \q # 退出
运行exit离开postgres用户
> sudo wget http://download.redis.io/releases/redis-3.2.6.tar.gz
> sudo tar -zxvf redis-3.2.6.tar.gz
> sudo cp -rf redis-3.2.6 /usr/local/redis
> cd /usr/local/redis
> sudo apt install gcc
> sudo make
> sudo make install
如果提示make test, 则输入make test
运行redis-server 启动redis
sudo apt install python-setuptools python-dev libxslt1-dev gcc libffi-dev libjpeg-dev libxml2-dev libxslt-dev libyaml-dev libpq-dev
下载get-pip.py
> wget "https://bootstrap.pypa.io/get-pip.py"
> sudo python get-pip.py
> pip install -U virtualenv
> sudo mkdir /var/www
> sudo chmod -R 777 /var/www
> cd /var/www/
> mkdir sentry
> cd sentry
> virtualenv venv
> source venv/bin/activate
> pip install -U sentry
> sentry
Usage: sentry [OPTIONS] COMMAND [ARGS]...
Sentry is cross-platform crash reporting built with love.
The configuration file is looked up in the `~/.sentry` config directory but this can
be overridden with the `SENTRY_CONF` environment variable or be explicitly provided
through the `--config` parameter.
Options:
--config PATH Path to configuration files.
--version Show the version and exit.
--help Show this message and exit.
Commands:
celery DEPRECATED see `sentry run` instead.
cleanup Delete a portion of trailing data based on...
config Manage runtime config options.
createuser Create a new user.
devserver Starts a lightweight web server for...
django Execute Django subcommands.
dsym Manage system symbols in Sentry.
export Exports core metadata for the Sentry...
files Manage files from filestore.
help Show this message and exit.
import Imports data from a Sentry export.
init Initialize new configuration directory.
plugins Manage Sentry plugins.
queues Manage Sentry queues.
repair Attempt to repair any invalid data.
run Run a service.
shell Run a Python interactive interpreter.
start DEPRECATED see `sentry run` instead.
tsdb Tools for interacting with the time series...
upgrade Perform any pending database migrations and...
sentry init 配置文件路径
> sentry init /var/www/sentry/conf
打开/var/www/sentry/conf/sentry.conf.py
修改下面这段
DATABASES = {
'default': {
'ENGINE': 'sentry.db.postgres',
'NAME': 'sentry',
'USER': 'postgres',
'PASSWORD': '123123', # 刚才安装完postgreSQL 后你设置的密码
'HOST': '',
'PORT': '',
'AUTOCOMMIT': True,
'ATOMIC_REQUESTS': False,
}
}
> createdb -E utf-8 sentry
如果提示createdb: could not connect to database template1: FATAL: role "lin" does not exist
则切换到postgre用户执行
执行
SENTRY_CONF=/var/www/sentry/conf/ sentry upgrade
如果提示OperationalError: FATAL: Peer authentication failed for user "postgres"
解决方案:
local all postgres peer
local all all peer
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
为
local all postgres md5
local all all peer
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
3. 重启postgresql
sudo service postgresql restart
再次执行
SENTRY_CONF=/var/www/sentry/conf/ sentry upgrade
如果提示`sentry.exceptions.InvalidConfiguration: MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.`
解决方案:
1. 进入redis redis-cli
2. 执行
config set stop-writes-on-bgsave-error no
再次执行
再次执行 SENTRY_CONF=/var/www/sentry/conf/ sentry upgrade
在这一步执行完成后可能提示你是否要创建用户,则按照要求创建用户即可, 没有提示的话执行以下语句创建
SENTRY_CONF=/var/www/sentry/conf/ sentry createuser
## 五、运行服务
SENTRY_CONF=/var/www/sentry/conf/ sentry run web # 运行web服务
SENTRY_CONF=/var/www/sentry/conf/ sentry run worker # 运行日志搜集进程SENTRY_CONF=/var/www/sentry/conf/ sentry run cron # 启动cron进程
$client = new Raven_Client('http://f2c047b856bb41fcbf486f467b7fcf5b:aa2a33c7176d4c1fb86a3aa8cb4728aa@10.211.55.14:9000/1');
$error_handler = new Raven_ErrorHandler($client);
$error_handler->registerExceptionHandler();
$error_handler->registerErrorHandler();
$error_handler->registerShutdownFunction();
set_error_handler(array($error_handler, 'handleError'));
set_exception_handler(array($error_handler, 'handleException'));
$client->captureMessage("这里发生了一个错误");
$i = 1 / 0;
运行以后, 查看web端, 就会看到传输回来的错误了。
-----
![](/upload/otherpic60/29755.jpg)