Skip to content

Instantly share code, notes, and snippets.

@Code-Hex
Forked from saboyutaka/Makefile
Last active June 27, 2017 00:34
Show Gist options
  • Select an option

  • Save Code-Hex/000550def0c3c3f7c00e100840c427c0 to your computer and use it in GitHub Desktop.

Select an option

Save Code-Hex/000550def0c3c3f7c00e100840c427c0 to your computer and use it in GitHub Desktop.

Revisions

  1. Code-Hex revised this gist Jun 27, 2017. 1 changed file with 14 additions and 17 deletions.
    31 changes: 14 additions & 17 deletions Makefile
    Original file line number Diff line number Diff line change
    @@ -1,35 +1,32 @@
    .DEFAULT_GOAL := help

    config: ## copy configs from repository to conf
    @sudo cp ~/private_isu/webapp/conf/systemd/isu-ruby.service /etc/systemd/system/
    @sudo cp ~/private_isu/webapp/conf/nginx/nginx.conf /etc/nginx/
    @sudo cp ~/private_isu/webapp/conf/nginx/isucon.conf /etc/nginx/conf.d/
    @sudo cp ~/private_isu/webapp/conf/mysql/my.cnf /etc/mysql/
    @sudo cp ~/$HOME/webapp/conf/nginx/nginx.conf /etc/nginx/
    @sudo cp ~/$HOME/webapp/conf/nginx/isucon.conf /etc/nginx/conf.d/
    @sudo cp ~/$HOME/webapp/conf/mysql/my.cnf /etc/mysql/
    @make -s nginx-restart
    @make -s mysql-restart
    @make -s ruby-restart
    @make -s go-restart

    ruby-start: ## Run Server
    @sudo systemctl start isu-ruby
    go-start: ## Run Server
    @sudo systemctl start isu-go

    ruby-stop: ## Stop Server
    @sudo systemctl stop isu-ruby
    go-stop: ## Stop Server
    @sudo systemctl stop isu-go

    ruby-log: ## log Server
    @sudo journalctl -u isu-ruby
    go-log: ## log Server
    @sudo journalctl -u isu-go

    ruby-restart: ## Restart Server
    @sudo systemctl daemon-reload
    @cd webapp/ruby; bundle 1> /dev/null
    @sudo systemctl restart isu-ruby
    @echo 'Restart isu-ruby'
    go-restart: ## Restart Server
    @sudo systemctl restart isu-go
    @echo 'Restart isu-go'

    nginx-restart: ## Restart nginx
    @sudo systemctl restart nginx
    @echo 'Restart nginx'

    nginx-reset-log: ## reest log and restart nginx
    @sudo rm /var/log/nginx/access.log;sudo service nginx restart
    @sudo rm /var/log/nginx/access.log;sudo systemctl restart nginx

    nginx-log: ## tail nginx access.log
    @sudo tail -f /var/log/nginx/access.log
  2. @saboyutaka saboyutaka revised this gist Jun 26, 2017. 1 changed file with 17 additions and 23 deletions.
    40 changes: 17 additions & 23 deletions Makefile
    Original file line number Diff line number Diff line change
    @@ -1,35 +1,31 @@
    .DEFAULT_GOAL := help

    start: ## Run Server
    @sudo systemctl start isu-ruby

    stop: ## Stop Server
    @sudo systemctl stop isu-ruby

    log: ## log Server
    @sudo journalctl -u isu-ruby

    config: ## copy configs from repository to conf
    @sudo cp ~/private_isu/webapp/conf/systemd/isu-ruby.service /etc/systemd/system/
    @sudo cp ~/private_isu/webapp/conf/nginx/nginx.conf /etc/nginx/
    @sudo cp ~/private_isu/webapp/conf/nginx/isucon.conf /etc/nginx/conf.d/
    @sudo cp ~/private_isu/webapp/conf/mysql/my.cnf /etc/mysql/
    @make -s restart
    @make -s nginx-restart
    @make -s db-restart
    @make -s mysql-restart
    @make -s ruby-restart

    ruby-start: ## Run Server
    @sudo systemctl start isu-ruby

    ruby-stop: ## Stop Server
    @sudo systemctl stop isu-ruby

    ruby-log: ## log Server
    @sudo journalctl -u isu-ruby

    restart: ## Restart Server
    ruby-restart: ## Restart Server
    @sudo systemctl daemon-reload
    @cd webapp/ruby; bundle 1> /dev/null
    @sudo systemctl restart isu-ruby
    @echo 'Restart isu-ruby'

    db-restart: ## Restart mysql
    @sudo service mysql restart
    @echo 'Restart mysql'

    nginx-restart: ## Restart nginx
    @sudo service nginx restart
    @sudo systemctl restart nginx
    @echo 'Restart nginx'

    nginx-reset-log: ## reest log and restart nginx
    @@ -41,15 +37,13 @@ nginx-log: ## tail nginx access.log
    nginx-error-log: ## tail nginx error.log
    @sudo tail -f /var/log/nginx/error.log

    mysql-restart: ## Restart mysql
    @sudo systemctl restart mysql
    @echo 'Restart mysql'

    myprofiler: ## Run myprofiler
    @myprofiler -user=root

    db-slow-query: ## tail slow query log
    @sudo tail -f /var/log/mysql/mysql-slow.log

    alp: ## nginx analyzer
    @sudo /home/isucon/gocode/bin/alp -f /var/log/nginx/access.log ${ARGS}

    .PHONY: help
    help:
    @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
  3. @saboyutaka saboyutaka created this gist Jun 23, 2017.
    55 changes: 55 additions & 0 deletions Makefile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,55 @@
    .DEFAULT_GOAL := help

    start: ## Run Server
    @sudo systemctl start isu-ruby

    stop: ## Stop Server
    @sudo systemctl stop isu-ruby

    log: ## log Server
    @sudo journalctl -u isu-ruby

    config: ## copy configs from repository to conf
    @sudo cp ~/private_isu/webapp/conf/systemd/isu-ruby.service /etc/systemd/system/
    @sudo cp ~/private_isu/webapp/conf/nginx/nginx.conf /etc/nginx/
    @sudo cp ~/private_isu/webapp/conf/nginx/isucon.conf /etc/nginx/conf.d/
    @sudo cp ~/private_isu/webapp/conf/mysql/my.cnf /etc/mysql/
    @make -s restart
    @make -s nginx-restart
    @make -s db-restart

    restart: ## Restart Server
    @sudo systemctl daemon-reload
    @cd webapp/ruby; bundle 1> /dev/null
    @sudo systemctl restart isu-ruby
    @echo 'Restart isu-ruby'

    db-restart: ## Restart mysql
    @sudo service mysql restart
    @echo 'Restart mysql'

    nginx-restart: ## Restart nginx
    @sudo service nginx restart
    @echo 'Restart nginx'

    nginx-reset-log: ## reest log and restart nginx
    @sudo rm /var/log/nginx/access.log;sudo service nginx restart

    nginx-log: ## tail nginx access.log
    @sudo tail -f /var/log/nginx/access.log

    nginx-error-log: ## tail nginx error.log
    @sudo tail -f /var/log/nginx/error.log

    myprofiler: ## Run myprofiler
    @myprofiler -user=root

    db-slow-query: ## tail slow query log
    @sudo tail -f /var/log/mysql/mysql-slow.log

    alp: ## nginx analyzer
    @sudo /home/isucon/gocode/bin/alp -f /var/log/nginx/access.log ${ARGS}

    .PHONY: help
    help:
    @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'