20 October 2014

前记


原本应该周六周末完成的事情,结果,却去看动漫了,然后周一,工作日做着搭建Gitlab本地环境的事情。很想,知道,新版的Rails,和旧版的Rails究竟会存在怎样的区别和变化。以下,是自己尝试过程中的一些记录。

安装问题

  • gem install charlock_holmes -v '0.6.9.4'安装失败,仔细查看出错日志,详细的信息参考mkmf.log。寻找mkmf.log,使用locate命令。发现,缺失如下的库: /usr/bin/ld: cannot find -licui18n。在charlock_holmes上找到了名为icu的相关的库,安装的命令是apt-get install icu-devtools libicu-dev

关于libicu-dev以及icu::(全称为: International Components for Unicode),

  • gem install rugged -v '0.21.0'安装失败,rugged是libgit2的包装,所以需要安装libgit2-dev。目测,RVM的工作方式都是下载源代码,然后本地编译安装,rugged编译需要cmake。
  • gem install pg -v '0.15.1'安装失败,将pg gem包注释掉,原因是不需要使用该gem包,因为不打算使用postgreSQL
  • rake db:migrate 失败了,说是/home/git/repositories/root目录不存在,在参考了官方文档之后,发现需要新建git用户。具体的操作命令如下:
  • /home/git/gitlab-shell/bin/xxx文件不存在或者没有权限,搞了半天,才知道gitlab-shell也是一个项目,clone下来后,运行gitlab:shell:setup,又出现了新的错误,.ssh/authorized_keys文件没有权限,chmod 777之后,发现居然就加了一句话进去了。坑我啊。不过,就算gitlab:shell:setup运行失败了,应用程序也还是可以打开的。算了,不想折腾了。

    cd /home
    useradd git
    mkdir git && cd git && mkdir repositories && cd repositories && mkdir root
    chown git:git  -R git/
    chmod 777  -R git/repositories/root
    

历经多次bundle error,终于将Gitlab依赖的Gem包安装成功了,接下来,恢复数据库: rake db:migrate,居然又一次失败了,看来,不参考官方的文档,是不能正确的安装完成的,随意看了看,也没仔细看。

项目分析

Gitlab提供的Rake任务(备注,Rake任务存放在lib/task目录下的rake文件中):

  rake about                                      # List versions of all Rails frameworks and the environment
  rake add_limits_mysql                           # GITLAB | Add limits to strings in mysql database
  rake assets:clean[keep]                         # Remove old compiled assets
  rake assets:clobber                             # Remove compiled assets
  rake assets:environment                         # Load asset compile environment
  rake assets:precompile                          # Compile all the assets named in config.assets.precompile
  rake cache:clear                                # GITLAB | Clear redis cache
  rake cache_digests:dependencies                 # Lookup first-level dependencies for TEMPLATE (like messages/show or comments/_comment.html)
  rake cache_digests:nested_dependencies          # Lookup nested dependencies for TEMPLATE (like messages/show or comments/_comment.html)
  rake db:create                                  # Creates the database from DATABASE_URL or config/database.yml for the current RAILS_ENV (use db:create:all to create all databases in the co..
  rake db:drop                                    # Drops the database from DATABASE_URL or config/database.yml for the current RAILS_ENV (use db:drop:all to drop all databases in the config)
  rake db:fixtures:load                           # Load fixtures into the current environment's database
  rake db:migrate                                 # Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)
  rake db:migrate:status                          # Display status of migrations
  rake db:rollback                                # Rolls the schema back to the previous version (specify steps w/ STEP=n)
  rake db:schema:cache:clear                      # Clear a db/schema_cache.dump file
  rake db:schema:cache:dump                       # Create a db/schema_cache.dump file
  rake db:schema:dump                             # Create a db/schema.rb file that is portable against any DB supported by AR
  rake db:schema:load                             # Load a schema.rb file into the database
  rake db:seed                                    # Load the seed data from db/seeds.rb
  rake db:seed_fu                                 # Loads seed data for the current environment
  rake db:setup                                   # Create the database, load the schema, and initialize with the seed data (use db:reset to also drop the database first)
  rake db:structure:dump                          # Dump the database structure to db/structure.sql
  rake db:version                                 # Retrieves the current schema version number
  rake dev:setup                                  # GITLAB | Setup developer environment (db, fixtures)
  rake doc:app                                    # Generate docs for the app -- also available doc:rails, doc:guides (options: TEMPLATE=/rdoc-template.rb, TITLE="Custom Title")
  rake emoji:install_assets                       # Install Emoji Image Assets
  rake gitlab:app:check                           # GITLAB | Check the configuration of the GitLab Rails app
  rake gitlab:backup:create                       # GITLAB | Create a backup of the GitLab system
  rake gitlab:backup:restore                      # GITLAB | Restore a previously created backup
  rake gitlab:check                               # GITLAB | Check the configuration of GitLab and its environment
  rake gitlab:cleanup:block_removed_ldap_users    # GITLAB | Cleanup | Block users that have been removed in LDAP
  rake gitlab:cleanup:dirs                        # GITLAB | Cleanup | Clean namespaces
  rake gitlab:cleanup:repos                       # GITLAB | Cleanup | Clean repositories
  rake gitlab:env:check                           # GITLAB | Check the configuration of the environment
  rake gitlab:env:info                            # GITLAB | Show information about GitLab and its environment
  rake gitlab:generate_docs                       # GITLAB | Generate sdocs for project
  rake gitlab:gitlab_shell:check                  # GITLAB | Check the configuration of GitLab Shell
  rake gitlab:import:all_users_to_all_groups      # GITLAB | Add all users to all groups (admin users are added as owners)
  rake gitlab:import:all_users_to_all_projects    # GITLAB | Add all users to all projects (admin users are added as masters)
  rake gitlab:import:repos                        # GITLAB | Import bare repositories from gitlab_shell -> repos_path into GitLab project instance
  rake gitlab:import:user_to_groups[email]        # GITLAB | Add a specific user to all groups (as a developer)
  rake gitlab:import:user_to_projects[email]      # GITLAB | Add a specific user to all projects (as a developer)
  rake gitlab:satellites:create                   # GITLAB | Create satellite repos
  rake gitlab:setup                               # GITLAB | Setup production application
  rake gitlab:shell:build_missing_projects        # GITLAB | Build missing projects
  rake gitlab:shell:install[tag,repo]             # GITLAB | Install or upgrade gitlab-shell
  rake gitlab:shell:setup                         # GITLAB | Setup gitlab-shell
  rake gitlab:sidekiq:check                       # GITLAB | Check the configuration of Sidekiq
  rake gitlab:sidekiq:drop_post_receive[project]  # Drop all Sidekiq PostReceive jobs for a given project
  rake gitlab:test                                # GITLAB | Run all tests
  rake gitlab:web_hook:add                        # GITLAB | Adds a web hook to the projects
  rake gitlab:web_hook:list                       # GITLAB | List web hooks
  rake gitlab:web_hook:rm                         # GITLAB | Remove a web hook from the projects
  rake hipchat:send[message]                      # Sends a HipChat message as a particular user
  rake jasmine                                    # Run specs via server:ci
  rake jasmine:ci                                 # Run continuous integration tests
  rake log:clear                                  # Truncates all *.log files in log/ to zero bytes (specify which logs with LOGS=test,development)
  rake middleware                                 # Prints out your Rack middleware stack
  rake migrate_iids                               # GITLAB | Build internal ids for issues and merge requests
  rake notes                                      # Enumerate all annotations (use notes:optimize, :fixme, :todo for focus)
  rake notes:custom                               # Enumerate a custom annotation, specify with ANNOTATION=CUSTOM
  rake rails:template                             # Applies the template supplied by LOCATION=(/path/to/template) or URL
  rake rails:update                               # Update configs and some other initially generated files (or use just update:configs or update:bin)
  rake routes                                     # Print out all defined routes in match order, with names
  rake secret                                     # Generate a cryptographically secure secret key (this is typically used to generate a secret for cookie sessions)
  rake setup                                      # GITLAB | Setup gitlab db
  rake sidekiq:launchd                            # GITLAB | Start sidekiq with launchd on Mac OS X
  rake sidekiq:restart                            # GitLab | Restart sidekiq
  rake sidekiq:start                              # GITLAB | Start sidekiq
  rake sidekiq:stop                               # GITLAB | Stop sidekiq
  rake spec                                       # GITLAB | Run specs
  rake spec:api                                   # GITLAB | Run request specs
  rake spec:controllers                           # Run the code examples in spec/controllers
  rake spec:feature                               # GITLAB | Run feature specs
  rake spec:features                              # Run the code examples in spec/features
  rake spec:finders                               # Run the code examples in spec/finders
  rake spec:helpers                               # Run the code examples in spec/helpers
  rake spec:lib                                   # Run the code examples in spec/lib
  rake spec:mailers                               # Run the code examples in spec/mailers
  rake spec:models                                # Run the code examples in spec/models
  rake spec:other                                 # GITLAB | Run other specs
  rake spec:requests                              # Run the code examples in spec/requests
  rake spec:routing                               # Run the code examples in spec/routing
  rake spec:services                              # Run the code examples in spec/services
  rake spec:tasks                                 # Run the code examples in spec/tasks
  rake spec:workers                               # Run the code examples in spec/workers
  rake spinach                                    # GITLAB | Run spinach
  rake spinach:generate                           # runs spinach and generates feature steps files when necessary
  rake spinach_other                              # GITLAB | Run other spinach features
  rake spinach_project                            # GITLAB | Run project spinach features
  rake state_machine:draw                         # Draws state machines using GraphViz (options: CLASS=User,Vehicle; FILE=user.rb,vehicle.rb [not required in Rails / Merb]; FONT=Arial; FORMAT...
  rake stats                                      # Report code statistics (KLOCs, etc) from the application
  rake test                                       # GITLAB | Run all tests
  rake test:all                                   # Run tests quickly by merging all types and not resetting db
  rake test:all:db                                # Run tests quickly, but also reset db
  rake time:zones:all                             # Displays all time zones, also available: time:zones:us, time:zones:local -- filter with OFFSET parameter, e.g., OFFSET=-6
  rake tmp:clear                                  # Clear session, cache, and socket files from tmp/ (narrow w/ tmp:sessions:clear, tmp:cache:clear, tmp:sockets:clear)
  rake tmp:create                                 # Creates tmp directories for sessions, cache, sockets, and pids

备注:为何记录下来? Rake执行起来实在太慢了。

Gitlab集群

Gitlab集群示意图:

小记:关于bundle抑或是rubygems,有一点,我觉得不如apt-get,每次都要从服务器上Fetch下源的index,相当的缓慢。解析包的依赖管理过于缓慢,且很耗CPU,可以建立本地缓存从而加快速度。

我总是做着不合时宜的事情,好不容易搭建完了环境,开始学习吧。说道开始学习,但是从哪里下手,自己想想了,还是先从文档开始下手。

经验:

Rails项目貌似都是源代码部署,所以,开源的似乎顺理成章。

参考文献


  1. GitLab安装笔记
  2. 某个时期,Gitlab文档的翻译版



傲娇的使用Disqus