User Tools

Site Tools


quick:gitlab_setup

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
quick:gitlab_setup [2021/03/20 22:35]
bbarsch
— (current)
Line 1: Line 1:
-====== Procedure to update user db code ====== 
- 
- 
-===== Clone the userdb code from the Gitlab Repo===== 
-1. Go to the directory you want to clone the repo to 
- 
- 
-2. Go to the repo in Gitlab and copy the ssh link: 
-<code> 
-git@git:protea/protea_database.git 
-</code> 
- 
-3. Note that git should be pointing to scp and not lengau, therefore in my .ssh/config file git2 points to scp so I use ''git clone git@git2:protea/protea_database.git'': 
- 
-<code> 
-BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb 
-$ git clone git@git2:protea/protea_database.git 
-Cloning into 'protea_database'... 
-Enter passphrase for key '/c/Users/BBarsch/.ssh/id_dsa': 
-remote: Enumerating objects: 425, done. 
- 
-</code> 
- 
-Passphrase was Csir20... 
- 
- 
-4. Open your IDE, using sublime, and make changes to the code. 
- 
-<code> 
-BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb 
-$ cd protea_database/ 
- 
-BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (master) 
-$ 
- 
-</code> 
- 
-5. Save the code and check the ''git status'' to make sure you are up-to-date: 
- 
-<code> 
-BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (master) 
-$ git status 
-On branch master 
-Your branch is up to date with 'origin/master'. 
- 
-nothing to commit, working tree clean 
- 
-BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (master) 
-$ 
- 
-</code> 
- 
- 
- 
-6. Next step is to push the code 
- 
-===== Push the code back to Gitlab - Master ===== 
- 
-1. Update, add, delete code and files. For demonstration we will just modify the README.md text for example. 
-Then go to that directory you did the clone from and hence the update and say ''git status'': 
-   
-<code> 
-BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (master) 
-$ git status 
-On branch master 
-Your branch is up to date with 'origin/master'. 
- 
-Changes not staged for commit: 
-  (use "git add <file>..." to update what will be committed) 
-  (use "git restore <file>..." to discard changes in working directory) 
-        modified:   README.md 
- 
-no changes added to commit (use "git add" and/or "git commit -a") 
- 
-BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (master) 
-$ 
- 
- 
-</code> 
- 
-2. this should show something is modified, and recommends you do ''git add .'' or ''git add <filename>'': 
- 
-<code> 
-BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (master) 
-$ git add README.md 
- 
-</code> 
- 
-4. Then do a commit ''git commit -m "commit comment"'': 
- 
-<code> 
-BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (master) 
-$ git commit -m "18-Feb-2021 Test Commit" 
-[master b7ea92ab] 18-Feb-2021 Test Commit 
- 1 file changed, 3 insertions(+) 
- 
- 
-</code> 
- 
- 
-5. And check with git status again that it has been added 
- 
-<code> 
-BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (master) 
-$ git status 
-On branch master 
-Your branch is ahead of 'origin/master' by 1 commit. 
-  (use "git push" to publish your local commits) 
- 
-nothing to commit, working tree clean 
-</code> 
- 
- 
-6. Then lastly push the code to gitlab use ''git push'': 
- 
-<code> 
-BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (master) 
-$ git push 
-Enter passphrase for key '/c/Users/BBarsch/.ssh/id_dsa': 
-Enumerating objects: 5, done. 
-Counting objects: 100% (5/5), done. 
-Delta compression using up to 12 threads 
-Compressing objects: 100% (3/3), done. 
-Writing objects: 100% (3/3), 323 bytes | 161.00 KiB/s, done. 
-Total 3 (delta 2), reused 0 (delta 0), pack-reused 0 
-To git2:protea/protea_database.git 
-   b205ea3d..b7ea92ab  master -> master 
- 
- 
- 
-</code> 
-   
- 
-maybe asked for a passphrase, use ''Csir20...'' as its done through ''users.chpc'' or ''bio.chpc''. Not sure if you can do this without a password as ssh-copy-id did not make a difference. 
- 
-Next we need to update the user database 
- 
-===== Push the code back to Gitlab - "Branch" ===== 
-1. Update, add, delete code and files. For demonstration we will just modify the README.md text for example. Now change to another branch by using ''git checkout -b bb_new_branch'': 
- 
-<code> 
-BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (master) 
-$ git checkout -b bb_new_branch 
-Switched to a new branch 'bb_new_branch' 
- 
-</code> 
- 
-2. Now check your status: 
- 
-<code> 
-BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (bb_new_branch) 
-$ git status 
-On branch bb_new_branch 
-Changes not staged for commit: 
-  (use "git add <file>..." to update what will be committed) 
-  (use "git restore <file>..." to discard changes in working directory) 
-        modified:   README.md 
- 
-no changes added to commit (use "git add" and/or "git commit -a") 
- 
- 
-</code> 
- 
-3. Now add ''README.md'' and check the status: 
- 
-<code> 
-BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (bb_new_branch) 
-$ git add README.md 
- 
-BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (bb_new_branch) 
-$ git status 
-On branch bb_new_branch 
-Changes to be committed: 
-  (use "git restore --staged <file>..." to unstage) 
-        modified:   README.md 
- 
- 
-</code> 
- 
-4. Then make the commit: 
- 
-<code> 
-BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (bb_new_branch) 
-$ git commit -m "Test push" 
-[bb_new_branch 785e724a] Test push 
- 1 file changed, 3 insertions(+) 
- 
- 
-</code> 
- 
-5. Then push the code: 
- 
-<code> 
-BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (bb_new_branch) 
-$ git push 
-fatal: The current branch bb_new_branch has no upstream branch. 
-To push the current branch and set the remote as upstream, use 
- 
-    git push --set-upstream origin bb_new_branch 
- 
-</code> 
- 
-6. Note this is different to how you do it with ''master'' you have to ''upstream'': 
- 
-<code> 
- 
-BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (bb_new_branch) 
-$ git push --set-upstream origin bb_new_branch 
-Enter passphrase for key '/c/Users/BBarsch/.ssh/id_dsa': 
-Enumerating objects: 5, done. 
-Counting objects: 100% (5/5), done. 
-Delta compression using up to 12 threads 
-Compressing objects: 100% (3/3), done. 
-Writing objects: 100% (3/3), 311 bytes | 311.00 KiB/s, done. 
-Total 3 (delta 2), reused 0 (delta 0), pack-reused 0 
-remote: 
-remote: To create a merge request for bb_new_branch, visit: 
-remote:   http://git.chpc.ac.za/protea/protea_database/-/merge_requests/new?merge_request%5Bsource_branch%5D=bb_new_branch 
-remote: 
-To git2:protea/protea_database.git 
- * [new branch]        bb_new_branch -> bb_new_branch 
-Branch 'bb_new_branch' set up to track remote branch 'bb_new_branch' from 'origin'. 
- 
- 
-</code> 
- 
-Now when you try to merge on Gitlab: 
- 
-{{quick:merge_req.png}} 
- 
-===== Update the userdb server ===== 
- 
-1.  Login in to the cluster (login2) by using the following command. (replace bbarsch with your username) 
- 
-  ssh bbarsch@lengau.chpc.ac.za 
- 
-2. Then ssh to users (Password is P@...): 
- 
-  ssh bbarsch@users2.chpc.ac.za  
- 
-3. Login as root user (superuser...note you need admin permission): 
- 
-  sudo su - 
- 
-4. Connect to chpc: 
- 
-  su - chpc 
- 
-5. Go to the user database directory: 
- 
-  cd protea_database/ 
- 
-6. Check the git status if any changes exist: 
- 
-  git status 
- 
-7. Downloads commits, files, and refs from a remote repository into your local repo by using git fetch: 
- 
-  git fetch 
- 
-8. Check if any local changes exist: 
- 
-  git stash 
- 
-9. Pull any changes from the repo: 
- 
-  git pull 
- 
-10. Pull any changes from submodules (helpdesk) linked to this repo: 
- 
-  git submodule update 
- 
-11. Get back in to root user by logging out from chpc using: 
- 
-  ctrl+d 
- 
-12. Restart the gunicorn service: 
- 
-  systemctl restart gunicorn.service 
- 
-13. Start ngninx: 
- 
-  systemctl start nginx 
- 
-14. Flush redis: 
- 
-  redis-cli flushall 
- 
-15. Close the terminal and go to the users2 site on a browser to see changes: 
- 
-  users2.chpc.ac.za 
- 
-- Note to do the same for usersdev you must tunnel in as its internal, use the command: 
- 
-  ssh -N -L 8888:usersdev.chpc.ac.za:80 scp.chpc.ac.za 
- 
-- then go to localhost:8888 
- 
-example 
- 
-<code> 
-BBarsch@BBARSCH-NB1 MINGW64 ~ 
-$ ssh bbarsch@lengau.chpc.ac.za 
-######################################################################## 
-#                                                                      # 
-# Dear CHPC User                                                       # 
-#                                                                      # 
-# Please note that the scheduled maintenance work will be performed on # 
-# Friday, 26 Mar 2021. The Lengau cluster will be unavailable for use  # 
-# from 8:00 in the morning to 17:00 in the afternoon on this day.      # 
-# During this time no jobs will be able to run or queue.               # 
-#                                                                      # 
-# Thank you for your understanding and kind regards                    # 
-# The CHPC Team                                                        # 
-#                                                                      # 
-######################################################################## 
-Last login: Sat Mar 20 19:47:31 2021 from 41.13.224.145 
- 
-Welcome to LENGAU 
- 
-################################################################################ 
-#                                                                              # 
-# In order to receive notifications via email from the CHPC all users should   # 
-# be subscribed to the CHPC user distribution list. If you are not part of the # 
-# distribution list you can subscribe at the following link:                   # 
-# https://lists.chpc.ac.za/mailman/listinfo/chpc-users                         # 
-#                                                                              # 
-################################################################################ 
-[bbarsch@login2 ~]$ ssh bbarsch@users2.chpc.ac.za 
-Password: 
-Last login: Sat Mar 20 19:47:51 2021 from lengau 
-[bbarsch@Users2 ~]$ sudo su - 
-Last login: Sat Mar 20 19:47:57 SAST 2021 on pts/0 
-[root@Users2 ~]# su - chpc 
-Last login: Sat Mar 20 19:48:03 SAST 2021 on pts/0 
-[chpc@Users2 ~]$ cd protea_database/ 
-[chpc@Users2 protea_database]$ git status 
-# On branch master 
-# Untracked files: 
-#   (use "git add <file>..." to include in what will be committed) 
-# 
-#       get_userdb.sh 
-#       media 
-#       penv/ 
-#       reports/views.py.ori 
-#       static/admin 
-#       static/favicon.ico 
-#       static/helpdesk 
-#       static/pygal-tooltips.min.js 
-#       static/reports 
-#       test.py 
-#       test2conn.py 
-#       testdbconn.py 
-#       userdb/settings.py.ori 
-#       userdb_uwsgi.ini 
-#       uwsgi_params 
-#       wsgi.py 
-nothing added to commit but untracked files present (use "git add" to track) 
-[chpc@Users2 protea_database]$ git fetch 
-remote: Enumerating objects: 5, done. 
-remote: Counting objects: 100% (5/5), done. 
-remote: Compressing objects: 100% (5/5), done. 
- 
-Unpacking objects: 100% (5/5), done. 
-From git.chpc.ac.za:protea/protea_database 
-   63f5846..66164de  master     -> origin/master 
-[chpc@Users2 protea_database]$ git pull 
-Updating 63f5846..66164de 
-Fast-forward 
- README.md      | 9 +++++++++ 
- chpc/graphs.py | 9 ++++++++- 
- 2 files changed, 17 insertions(+), 1 deletion(-) 
-[chpc@Users2 protea_database]$ logout 
-[root@Users2 ~]# systemctl restart gunicorn.service 
-[root@Users2 ~]# systemctl start nginx 
-[root@Users2 ~]# redis-cli flushall 
-OK 
-[root@Users2 ~]# 
- 
-</code> 
- 
  
/app/dokuwiki/data/attic/quick/gitlab_setup.1616272557.txt.gz · Last modified: 2021/12/09 16:42 (external edit)