varonRejected=console.error.bind(console);varpromise=Promise.resolve();promise.then(function(){returnPromise.reject(newError("this promise is rejected"));}).catch(onRejected);
<?xmlversion="1.0"encoding="UTF-8"?><!DOCTYPEplistPUBLIC"-//Apple//DTD PLIST 1.0//EN""http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plistversion="1.0"><dict><key>Label</key> <string>homebrew.mxcl.polipo</string><key>RunAtLoad</key> <true/><key>KeepAlive</key> <true/><key>ProgramArguments</key> <array> <string>/usr/local/opt/polipo/bin/polipo</string> <string>socksParentProxy=localhost:1080</string></array> <!-- Set `ulimit -n 65536`. The default macOS limit is 256, that's not enough for Polipo (displays 'too many files open' errors). It seems like you have no reason to lower this limit (and unlikely will want to raise it). --> <key>SoftResourceLimits</key><dict><key>NumberOfFiles</key> <integer>65536</integer></dict> </dict></plist>
classPerson<ActiveRecord::Base# 这样删除一个 person 时,还会删除名下的所有 contactshas_many:contacts,dependent::destroyendclassContact<ActiveRecord::Basebelongs_to:personend
sethttpdport2812anduseaddress172.16.10.6allowlocalhost# 允许本地访问allow172.16.20.0/255.255.255.0#允许本 IP 段访问allowadmin:monit# require user 'admin' with password 'monit'
<!--检查周期,单位为秒-->setdaemon120<!--日志文件位置-->setlogfile/var/log/monit.log<!--存储monit实例的唯一ID-->setidfile/var/lib/monit/id<!--存放监控进程的情况-->setstatefile/var/lib/monit/state<!--设置邮件-->setmailserversmtp.aa.comport25USERNAME"aa@aa.com"PASSWORD"123456"# 如果没配置 email, 会自动丢弃 alert# 该设置可以保存 alertseteventqueuebasedir/var/lib/monit/eventsslots100<!--Email格式-->setmail-format{from:monit@$HOSTsubject:monitalert--$EVENT$SERVICEmessage:$EVENTService$SERVICEDate:$DATEAction:$ACTIONHost:$HOSTDescription:$DESCRIPTIONYourfaithfulemployee,Monit}# 制定报警邮件的格式setmail-format{from:aa@aa.comsubject:$SERVICE$EVENTat$DATEmessage:Monit$ACTION$SERVICEat$DATEon$HOST:$DESCRIPTION.}<!--Email接收人-->setalertsysadm@foo.barwithreminderon3cycles<!--开启http服务,查看监控情况-->sethttpdport2812anduseaddress172.16.10.6# only accept connection from localhost#allow localhost#allow 172.16.20.0/255.255.255.0#allow 10.0.0.0 # allow localhost to connect to the server andallowadmin:monit# require user 'admin' with password 'monit'# allow @monit # allow users of group 'monit' to connect (rw)# allow @users readonly # allow users of group 'users' to connect readonlyinclude/etc/monit/conf.d/*
# Load DSL and Setup Up Stagesrequire'capistrano/setup'require'capistrano/deploy'#require'capistrano/rvm'require'capistrano/bundler'require'capistrano/rails/assets'require'capistrano/rails/migrations'require'capistrano/sidekiq'# 打开 monit 的监控 tasksrequire'capistrano/sidekiq/monit'require'capistrano/puma'# 打开 monit 的监控 tasksrequire'capistrano/puma/monit'# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.Dir.glob('lib/capistrano/tasks/*.rake').each{|r|importr}
# This is an upstart script to keep monit running.# To install disable the old way of doing things:## /etc/init.d/monit stop && update-rc.d -f monit remove## then put this script here:## /etc/init/monit.conf## and reload upstart configuration:## initctl reload-configuration## You can manually start and stop monit like this:# # start monit# stop monit#description"Monit service manager"limitcoreunlimitedunlimitedstartonrunlevel[2345]stoponstartingrcRUNLEVEL=[016]expectdaemonrespawnexec/usr/local/bin/monit-c/etc/monit/monitrcpre-stopexec/usr/local/bin/monit-c/etc/monit/monitrcquit
# File activemodel/lib/active_model/validations.rb, line 331defvalid?(context=nil)current_context,self.validation_context=validation_context,contexterrors.clearrun_validations!ensureself.validation_context=current_contextend# File activemodel/lib/active_model/validations.rb, line 394defrun_validations!_run_validate_callbackserrors.empty?end
# config valid only for current version of Capistranolock'3.4.0'set:application,'xgroup'set:repo_url,'git@github.com:linjunzhugg/xx.git'set:deploy_to,'/mnt/xgroup'set:scm,:git# Default value for :linked_files is []set:linked_files,%w{config/database.yml config/oauth2.yml config/redis.yml config/secrets.yml}# Default value for linked_dirs is []set:linked_dirs,%w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle}set:keep_releases,5namespace:deploydoafter:restart,:clear_cachedoonroles(:web),in::groups,limit:3,wait:10do# Here we can do anything such as:# within release_path do# execute :rake, 'cache:clear'# endendendafter:finishing,'deploy:cleanup'end
production.rb
1234567891011121314151617181920212223242526
# Simple Role Syntaxset:rvm_type,:userset:rvm_ruby_string,'ruby-2.2.1'set:branch,"master"server'0.0.0.0',user:'deployer',roles:%w{app}# 针对 puma 的配置set:puma_rackup,->{File.join(current_path,'config.ru')}set:puma_state,"#{shared_path}/tmp/pids/puma.state"set:puma_pid,"#{shared_path}/tmp/pids/puma.pid"set:puma_bind,"unix://#{shared_path}/tmp/sockets/puma.sock"#accept array for multi-bindset:puma_conf,"#{shared_path}/puma.rb"set:puma_access_log,"#{shared_path}/log/puma_error.log"set:puma_error_log,"#{shared_path}/log/puma_access.log"set:puma_role,:appset:puma_env,fetch(:rack_env,fetch(:rails_env,'production'))set:puma_threads,[0,120]set:puma_workers,0set:puma_worker_timeout,nilset:puma_init_active_record,falseset:puma_preload_app,true# 最终会创建 shared/puma.rb,将配置写进去,然后调用
envrioments/production.rb
123456
# Disable serving static files from the `/public` folder by default sinc# Apache or NGINX already handles this.config.serve_static_files=ENV['RAILS_SERVE_STATIC_FILES'].present# important!!!# 在 production.rb 有这么个配置,决定服务器是否伺服静态文件,默认服务器没设这个变量,因此为 false, 默认不伺服静态文件