📜 ⬆️ ⬇️

Deploy JetBrains Hub + Youtrack + Upsource + Nginx on your Debian 8 server

A few days ago I was faced with the task of deploying the development management system that JetBrains offers, namely to install Hub , Youtrack and Upsource while providing access to resources convenient for everyone.

After reading about the products and their installation on the server from zip archives, I decided to share my experience and ready solution ( script ) for automatic deployment with you.

hub + youtrack + upsource
')
I’ll say at once that there is nothing new that you wouldn’t find in the product documentation I’m not going to tell, I’ll tell you about some of the nuances and how to put the whole economy together.


It will be about products that are provided for linux in .zip archives.

Everything unfolded on the new Debian 8 server, which was only created in the cloud, that is, there was nothing on it except the most minimally necessary.

When setting up the system, I was guided by the following resources:


Server Recommendations


The instructions for Upsource say that the recommended characteristics for the system are:
  1. More than 8 GB of RAM.
  2. JRE or JDK 1.8 and newer.

Other recommendations for Upsource can read here .

About the installation process


The installation process is simple:
An example is shown for the hub, other products are installed one on one.
  1. Download the archive
    mkdir -p /usr/opt/jetbrains/hub cd /usr/opt/jetbrains/hub wget http://download.jetbrains.com/hub/1.0/hub-ring-bundle-1.0.529.zip 

  2. We unpack in the necessary directory which will be house for a product.
     unzip hub-ring-bundle-1.0.529.zip 

  3. And then according to the instructions, you can run the command (start for the background run):
     /usr/opt/jetbrains/hub/bin/hub.sh run 

  4. Then open yourdomain.local in browser: 8080
    And make the setting. Specify the host name and port.

But if you plan to use subdomains to access resources, and indeed the more correct way is to pre-configure the products to the correct port and host name, since they must listen to different ports at least.

To do this, before point 3, since we plan to use nginx as a proxy, we should add to the config / etc / nginx / sites-enabled / default at the beginning of the line:
 server { listen 80; listen [::]:80; server_name hub.yourdomain.local; server_tokens off; location / { proxy_set_header X-Forwarded-Host $http_host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_http_version 1.1; proxy_pass http://localhost:2222/; } } 

Make:
 service nginx reload 


And then you need to run the command:
 /usr/opt/jetbrains/hub/bin/hub.sh configure --listen-port 2222 --base-url http://hub.yourdomain.local 


Now you can perform the actual step 3 and go to the configured address hub.yourdomain.local .

About the bundle of products


First, the Hub is installed and configured, then you can configure Youtrack and Upsource.
Moreover, when configuring Youtrack and Upsource in the browser in the second step, you need to specify the hub that you configured.

IMPORTANT!
After configuring and configuring Youtrack and Upsource, and rebooting the server if the Hub has not yet started, then Youtrack and Upsource
will not be able to start and will fall with the error that the hub service does not exist. Therefore, they should be launched only after the successful launch of the Hub.

But neither the hub nor the other services themselves are written to autoload.

To do this, run the scripts to launch each product as a service:
 cat >/etc/init.d/hub <<EOF #! /bin/sh ### BEGIN INIT INFO # Provides: hub # Required-Start: \$local_fs \$remote_fs \$network \$syslog \$named # Required-Stop: \$local_fs \$remote_fs \$network \$syslog \$named # Default-Start: 2 3 4 5 # Default-Stop: S 0 1 6 # Short-Description: initscript for hub # Description: initscript for hub ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin NAME=hub SCRIPT=/usr/opt/jetbrains/\$NAME/bin/\$NAME.sh do_start() { \$SCRIPT start soft } case "\$1" in start) do_start ;; stop|restart|status|run|rerun|help) \$SCRIPT \$1 \$2 ;; *) echo "Usage: sudo /etc/init.d/hub {start|stop|restart|status|run|rerun}" >&2 exit 1 ;; esac exit 0 EOF chmod +x /etc/init.d/hub update-rc.d hub defaults 


For Youtrack and Upsource, you must additionally perform:
 update-rc.d youtrack disable 
Because they and so will not start themselves correctly.
For their correct start, you need to write a script for the @reboot
event for cron @reboot
that is waiting for the launch of api Hub

 mkdir -p /root/crons cat >/root/crons/jetbrains<<EOF #!/bin/bash status=404 while [ \$status -eq 404 ]; do echo "wait hub..." sleep 60 status=\`curl -s -o /dev/null -w "%{http_code}" http://hub.yourdomain.local/hub\` echo "hub status \$status" done service youtrack start service upsource start exit 0 EOF chmod +x /root/crons/jetbrains echo "@reboot /root/crons/jetbrains" > /tmp/cron_ crontab /tmp/cron_ 


Conclusion



Why am I here roughly told the instructions to JetBrains. Firstly, in order for you not to write a bike and have been able to use a ready-made solution . Yes, maybe my script is not a benchmark, but it is in the gist and anyone can correct the shoals and offer their expert opinion.
Secondly, I simply did not find a solution that would reduce my labor costs.

Thank you for attention.

PS Write about errors in lichku.

Source: https://habr.com/ru/post/266871/


All Articles