Install Arcanist Phabricator on Fedora 28

$ mkdir $HOME/arctools
$ cd $HOME/arctools
$ git clone https://github.com/phacility/libphutil.git
$ git clone https://github.com/phacility/arcanist.git
$ mv $HOME/arctools /opt
$ echo 'export PATH=$PATH:/opt/arctools/arcanist/bin' >> ~/.bash_profile
$ source ~/.bash_profile
$ sudo dnf install php php-json
$ arc --help
$ arc install-certificate
# and follow the rest of the instruction from the arc

Setup python app in centos from scratch (centos 6.9+uwsgi+nginx+flask+mysql)

Initial setup

$ sudo yum update
$ sudo yum install epel-release
$ sudo yum groupinstall "Development tools"
$ sudo yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel telnet htop
$ sudo yum install python-devel python-virtualenv
$ sudo yum install mysql-connector-python mysql-devel mysql-server

Install Python

Download and install Python : https://www.python.org/

./configure && make && make altinstall

Install uWSGI

$ wget https://bootstrap.pypa.io/get-pip.py
$ which python2.7
$ sudo /usr/local/bin/python2.7 get-pip.py
$ which pip2.7
$ sudo /usr/local/bin/pip2.7 install uWSGI
$ which uwsgi
$ uwsgi --version

Setup vassels

$ sudo mkdir -p /etc/uwsgi/vassels

Setup Emperor service

$ sudo vim /etc/init.d/emperor
#!/bin/sh
# chkconfig: 2345 99 10
# Description: Starts and stops the emperor-uwsgi
# See how we were called.
RUNEMPEROR="/usr/local/bin/uwsgi --emperor=/etc/uwsgi/vassels"
PIDFILE=/var/run/emperor-uwsgi.pid
LOGFILE=/var/log/uwsgi/emperor.log
start() {
if [ -f /var/run/$PIDNAME ] && kill -0 $(cat /var/run/$PIDNAME); then
echo 'Service emperor-uwsgi already running' >&2
return 1
fi
echo 'Starting Emperor...' >&2
local CMD="$RUNEMPEROR &> \"$LOGFILE\" & echo \$!"
su -c "$CMD" > "$PIDFILE"
echo 'Service started' >&2
}
stop() {
if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
echo 'Service emperor-uwsgi not running' >&2
return 1
fi
echo 'Stopping emperor-uwsgi' >&2
kill -7 $(cat "$PIDFILE") && rm -f "$PIDFILE"
echo 'Service stopped' >&2
}
status() {
if [ ! -f "$PIDFILE" ]; then
echo "Emperor is not running." >&2
return 1
else
echo "Emperor (pid  `cat ${PIDFILE}`) is running..."
ps -ef |grep `cat $PIDFILE`| grep -v grep
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
stop
start
;;
*)
echo "Usage: emperor {start|stop|restart}"
exit 1
esac

 Setup app user & environment

$ useradd foobar
$ usermod -md /srv/foobar foobar
$ chmod 755 /srv/foobar
$ sudo su - foobar
foobar@local~$ virtualenv --python=python2.7 ~/venv
foobar@local~$ mkdir www
foobar@local~$ mkdir logs
foobar@local~$ touch logs/uwsgi.log
foobar@local~$ touch uwsgi.ini
foobar@local~$ echo "source ~/venv/bin/activate" >> ~/.bashrc
foobar@local~$ source ~/venv/bin/activate
(venv)foobar@local~$ vim uwsgi.ini
[uwsgi]
master = true
processes = 2
socket = /tmp/foobar.sock
chdir = /srv/foobar/www
virtualenv = /srv/foobar/venv
module = app:app
uid = foobar
chown-socket = foobar:nginx
chmod-socket = 660
vacuum = true
die-on-term = true
python-autoreload = 3
py-autoreload = 1
logger = file:/srv/foobar/logs/uwsgi.log

Exit from foobar user & create uwsgi symlink

(venv)foobar@local~$ exit
$ sudo ln -s /srv/foobar/uwsgi.ini /etc/uwsgi/vassels/foobar.ini

Start emperor service & setup set the startup

$ sudo service emperor start
$ sudo chkconfig emperor on

Install google chrome in Fedora for the first time

When you install google chrome in fedora, you probably must have seen this error:

$ sudo rpm -i google-chrome-stable_current_x86_64.rpm
warning: google-chrome-stable_current_x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 7fac5991: NOKEY
error: Failed dependencies:
/usr/bin/lsb_release is needed by google-chrome-stable-68.0.3440.106-1.x86_64
[muffat@localhost Downloads]$ sudo rpm -i google-chrome-stable_current_x86_64.rpm 
warning: google-chrome-stable_current_x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 7fac5991: NOKEY
error: Failed dependencies:
/usr/bin/lsb_release is needed by google-chrome-stable-68.0.3440.106-1.x86_64

Try to install the dependencies:

$ sudo dnf install libappindicator-gtk3 vulkan redhat-lsb-core -y

And try again to install the chrome with rpm

How to move your old repo to github

Before you begin, you might want to add your ssh key into your github account.

// push master branch
$ cd /repo-directory
$ git remote rename origin bitbucket
$ git remote add origin https://github.com/username/awesome-new-repo.git
$ git push origin master
$ git remote rm bitbucket
// push another branch
$ git checkout develop
$ git push origin -u develop

How to fetching Username-Password credentials in Jenkinsfile

withCredentials([usernamePassword(credentialsId: 'my-creds', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
// available as an env variable, but will be masked if you try to print it out any which way
// note: single quotes prevent Groovy interpolation; expansion is by Bourne Shell, which is what you want
sh 'echo $PASSWORD > tmp'
// also available as a Groovy variable
echo USERNAME
// or inside double quotes for string interpolation
echo "username is $USERNAME"
}

Nginx config for staging application

resolver 172.17.0.1;
resolver_timeout 10s;
server {
listen 80;
server_name staging.app.com;
charset utf-8;
gzip_vary on;
access_log /var/log/nginx/app.access.log;
error_log /var/log/nginx/app.error.log;
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always;
add_header X-Frame-Options "SAMEORIGIN";
set $appweb http://app-web.service.consul;
location / {
proxy_pass $appweb:5002;
proxy_redirect     off;
proxy_set_header   Host $host;
proxy_set_header   X-Real-IP $remote_addr;
proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header   X-Forwarded-Host $server_name;
auth_basic "Private Property";
auth_basic_user_file /tmp/.htpasswd;
#allow xxx.xxx.xxx.xxx; # xxx
#deny all;
}
}