| 1 |
|
| 2 |
|
| 3 |
exec ruby -x "$0" "$@" |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
module Mikutter; end |
| 15 |
|
| 16 |
Regexp.timeout = 1.0 |
| 17 |
|
| 18 |
if !ENV.fetch('DISABLE_BUNDLER_SETUP', nil) || ['', '0'].include?(ENV.fetch('DISABLE_BUNDLER_SETUP', nil).to_s) |
| 19 |
begin |
| 20 |
ENV['BUNDLE_GEMFILE'] = File.expand_path(File.join(File.dirname($0), "Gemfile")) |
| 21 |
require 'bundler/setup' |
| 22 |
rescue LoadError, SystemExit |
| 23 |
存関係の解決に失敗した場合 |
| 24 |
使ってみる |
| 25 |
end |
| 26 |
end |
| 27 |
|
| 28 |
require_relative 'core/miquire' |
| 29 |
require 'boot/delayer' |
| 30 |
require 'boot/option' |
| 31 |
Mopt.parse exec_command: true |
| 32 |
|
| 33 |
ENV['LIBOVERLAY_SCROLLBAR'] = '0' |
| 34 |
|
| 35 |
require 'benchmark' |
| 36 |
require 'thread' |
| 37 |
require 'fileutils' |
| 38 |
|
| 39 |
require 'lib/diva_hacks' |
| 40 |
require 'lib/lazy' |
| 41 |
require 'lib/reserver' |
| 42 |
require 'lib/timelimitedqueue' |
| 43 |
require 'lib/uithreadonly' |
| 44 |
require 'lib/weakstorage' |
| 45 |
|
| 46 |
require_relative 'core/utils' |
| 47 |
|
| 48 |
require 'boot/check_config_permission' |
| 49 |
require 'boot/mainloop' |
| 50 |
require 'environment' |
| 51 |
|
| 52 |
Dir.chdir(Environment::CONFROOT) |
| 53 |
|
| 54 |
require 'system/system' |
| 55 |
|
| 56 |
require 'boot/load_plugin' |
| 57 |
|
| 58 |
Plugin.call(:boot, nil) |
| 59 |
|
| 60 |
の待受を開始する。 |
| 61 |
ングした結果を一時ディレクトリに保存する |
| 62 |
def boot!(profile) |
| 63 |
begin |
| 64 |
RubyVM::YJIT.enable if defined?(RubyVM::YJIT) |
| 65 |
if profile |
| 66 |
require 'ruby-prof' |
| 67 |
begin |
| 68 |
notice 'start profiling' |
| 69 |
RubyProf.start |
| 70 |
Mainloop.mainloop |
| 71 |
ensure |
| 72 |
result = RubyProf.stop |
| 73 |
printer = RubyProf::CallTreePrinter.new(result) |
| 74 |
path = File.join(Environment::TMPDIR, 'profile', Time.new.strftime('%Y-%m-%d-%H%M%S')) |
| 75 |
FileUtils.mkdir_p(path) |
| 76 |
notice "profile: writing to #{path}" |
| 77 |
printer.print(path: path) |
| 78 |
notice "profile: done." |
| 79 |
end |
| 80 |
else |
| 81 |
Mainloop.mainloop end |
| 82 |
rescue => exception |
| 83 |
into_debug_mode(exception) |
| 84 |
notice "catch exception `#{exception.class}'" |
| 85 |
raise |
| 86 |
rescue Exception => exception |
| 87 |
notice "catch exception `#{exception.class}'" |
| 88 |
exception = Mainloop.exception_filter(exception) |
| 89 |
notice "=> `#{exception.class}'" |
| 90 |
raise end |
| 91 |
exception = Mainloop.exception_filter(nil) |
| 92 |
if exception |
| 93 |
notice "raise mainloop exception `#{exception.class}'" |
| 94 |
raise exception end |
| 95 |
notice "boot! exited normally." end |
| 96 |
|
| 97 |
def error_handling!(exception) |
| 98 |
notice "catch #{exception.class}" |
| 99 |
if Mopt.debug && exception.respond_to?(:deferred) && exception.deferred |
| 100 |
if command_exist?('dot') |
| 101 |
notice "[[#{exception.deferred.graph_draw}]]" |
| 102 |
else |
| 103 |
notice exception.deferred.graph |
| 104 |
end |
| 105 |
end |
| 106 |
File.open(File.expand_path(File.join(Environment::TMPDIR, 'crashed_exception')), 'w'){ |io| Marshal.dump(exception, io) } rescue nil |
| 107 |
raise exception end |
| 108 |
|
| 109 |
begin |
| 110 |
errfile = File.join(File.expand_path(Environment::TMPDIR), 'mikutter_dump') |
| 111 |
File.rename(errfile, File.expand_path(File.join(Environment::TMPDIR, 'mikutter_error'))) if File.exist?(errfile) |
| 112 |
if not Mopt.debug |
| 113 |
$stderr = File.open(errfile, 'w') |
| 114 |
def $stderr.write(string) |
| 115 |
super(string) |
| 116 |
self.fsync rescue nil |
| 117 |
end |
| 118 |
$logger = nil 力先が新しい stderr になるようにする |
| 119 |
end |
| 120 |
boot!(Mopt.profile) |
| 121 |
if(Delayer.exception) |
| 122 |
raise Delayer.exception end |
| 123 |
rescue Interrupt, SystemExit, SignalException => exception |
| 124 |
notice "catch #{exception.class}" |
| 125 |
if Delayer.exception |
| 126 |
error_handling! Delayer.exception |
| 127 |
else |
| 128 |
File.delete(errfile) if File.exist?(errfile) |
| 129 |
raise exception end |
| 130 |
rescue Exception => exception |
| 131 |
error_handling! exception end |
| 132 |
notice "mainloop exited normally." |