-
Notifications
You must be signed in to change notification settings - Fork 4
Entwicklerhandbuch
Es gibt im Wiki eine weitere Seite mit Coding Conventions. Für Tests sind auch die Richtlinien von http://www.betterspecs.org/ hilfreich.
-
Die Änderung muss auf dem
master
-Branch committed sein. Es empfiehlt sich nicht, direkt auf demmaster
-Branch zu arbeiten -- Änderungen sollten zunächst auf einem anderen Branch vorgenommen werden und dann in denmaster
-Branch gemerge
t werden. -
Es muss eine
config/deploy.rb
-Datei angelegt werden. Es empfiehlt sich, dieconfig/deploy.example.rb
-Datei zu kopieren und den eigenen Nutzernamen auf dem Server unter:deploy_user
einzutragen. -
Eine SSH-Verbindung zum Server muss möglich sein. Dafür muss etwa eine VPN-Verbindung zu
vpn.hpi.de
bestehen. Es empfiehlt sich vorallem bei größeren Änderungen, zunächst auf den Staging-Server zu deployen, um die Änderungen in realistischer Umgebung zu testen:cap staging deploy
Dann kann mithilfe des Befehls
cap production deploy
(mithilfe des Gemscapistrano
) der aktuelle Stand desmaster
-Branches auf den Server deployed werden. Dabei werden auch automatisch die Gems so installiert, wie inGemfile.lock
beschrieben, und der Server-Prozess (unicorn
) auf dem Server neugestartet.
In config/initializers/errbit.rb
kann die URL einer Errbit-Instanz eingetragen werden. An diese werden dann alle schwerwiegenderen (nicht abgefangenen) Fehler während der Ausführung des Servers gesendet. Aktuell liegt diese Errbit-Instanz unter https://hpi-connect-errbit.herokuapp.com. Dort kann man sich einloggen und die Fehlermeldungen einsehen. Um schneller auf Fehler aufmerksam zu werden, empfiehlt sich auch, dort z.B. eine Weiterleitung in einen Slack-Channel einzurichten.
This project uses the simplecov
gem which generates a coverage report each time an RSpec run is completed. The report shows how often each line of code in every file is hit by the tests. Ideally, they should all be hit at least once to make sure the tests are able to catch as many mistakes as possible. The test coverage report can be found at coverage/index.html
.
Code-Änderungen sollten die Testabdeckung, wenn möglich, nicht senken.
Unicorn can be restarted using the command /etc/init.d/unicorn_hpi-career_production restart
.
Nginx can be restarted using the command /etc/init.d/nginx restart
.
The most important logs can be found at /var/logs/nginx/error.log
and /var/www/hpi-career/current/log/unicorn.log
.
Important: The SECRET_KEY_BASE
environment variable needs to be set for Unicorn to function correctly. If, for some reason, it becomes unset, the page will display an error message and unicorn.log
will show that SECRET_KEY_BASE
is missing. The following fix works:
/etc/init.d/unicorn_hpi-career_production stop
-
export SECRET_KEY_BASE=...
(A secret key can be generated withbundle exec rake secret
, for example.) /etc/init.d/unicorn_hpi-career_production start
This causes a short downtime, but is unavoidable, as Unicorn retains its environment variables during hot restarts (using restart
). For it to pick up new environment variables, it needs to be shut down fully and started again.
These commands need to be run locally (not on the server).
-
Run
bundle update
to update all gems as far as the Gemfile allows. This will updateGemfile.lock
. -
Run all tests and check if anything stopped working.
-
If everything is fine, commit and push all changes to (
Gemfile
and)Gemfile.lock
. The next time the project is deployed, Capistrano will automatically update the gems on the server.
This project uses Ruby Version Manager (RVM) to manage the current Ruby version. All of the following commands need to be executed on the server.
-
(Not always needed) If the currently installed version of RVM is out of date, it should be updated.
\curl -sSL https://get.rvm.io | sudo bash -s stable
rvm reload
-
Update to the newest available Ruby version and set it as default.
rvm install 2.x
rvm --default use 2.x
(where
2.x
is the version you want to update to) -
Copy the gemset.
rvm gemset copy <previous_version> <new_version>
-
Done!