-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathrun.sh
executable file
·80 lines (64 loc) · 1.76 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash -eux
app_lang="${ISHOCON_APP_LANG}"
if [ -z "$app_lang" ]
then
echo "ISHOCON_APP_LANG is not set"
exit 1
fi
echo "starting nginx and mysql..."
cd /home/ishocon
sudo nginx -t
sudo service nginx start
sudo chown -R mysql:mysql /var/lib/mysql
sudo service mysql start
echo "nginx and mysql started."
echo "setting up mysql user..."
sudo mysql -u root -pishocon -e 'CREATE DATABASE IF NOT EXISTS ishocon2;'
sudo mysql -u root -pishocon -e "CREATE USER IF NOT EXISTS ishocon IDENTIFIED BY 'ishocon';"
sudo mysql -u root -pishocon -e 'GRANT ALL ON *.* TO ishocon;'
echo "mysql user set up completed."
echo "importing data..."
tar -jxvf ~/data/ishocon2.dump.tar.bz2 -C ~/data && sudo mysql -u root -pishocon ishocon2 < ~/data/ishocon2.dump
echo "data imported."
check_message="start application w/ ${app_lang}..."
source /home/ishocon/.bashrc
echo "app_lang: $app_lang"
function make_tmp_file() {
touch /tmp/ishocon-app
echo "$check_message"
}
function run_ruby() {
cd "/home/ishocon/webapp/$app_lang"
sudo rm -rf /tmp/unicorn.pid
make_tmp_file
bundle exec unicorn -c unicorn_config.rb
}
function run_python() {
cd "/home/ishocon/webapp/$app_lang"
make_tmp_file
/home/ishocon/.pyenv/shims/uwsgi --ini app.ini
}
function run_go() {
cd "/home/ishocon/webapp/$app_lang"
make_tmp_file
/tmp/go/webapp
}
function run_php() {
cd "/home/ishocon/webapp/$app_lang"
sudo service php7.2-fpm restart
make_tmp_file
sudo tail -f /var/log/nginx/access.log /var/log/nginx/error.log
}
function run_nodejs() {
cd "/home/ishocon/webapp/$app_lang"
make_tmp_file
npm run start
}
function run_crystal() {
cd "/home/ishocon/webapp/$app_lang"
sudo shards install
make_tmp_file
sudo crystal app.cr
}
echo "starting running $app_lang app..."
"run_${app_lang}"