<commit_before>SHELL := /bin/bash
kill := /bin/kill

redis:
	pgrep redis &>/dev/null || sudo rc-service redis start

mongodb:
	pgrep mongod &> /dev/null || sudo rc-service mongodb start

run: redis mongodb
	bash -c "source env/bin/activate; \
	celery multi start spiderjob -A task.spider --pidfile=run/spider.pid --logfile=run/spider.log --loglevel=INFO; \
	uwsgi --ini-paste uwsgi.ini; \
	deactivate"

update:
	bash -c 'source env/bin/activate; \
	cat requirements.txt | cut -d= -f1 | while read package; do \
		pip install -U $${package}; \
	done; \
	deactivate'

stop:
	@echo "kill celery"
	@if [[ -e /run/spider.pid ]]; then \
		ps -ef | grep [c]elery | awk '{print $$2}' | xargs ${kill}; \
	fi
	@echo "kill uwsgi"
	@if [[ -e /run/uwsgi-spider.pid ]]; then \
		${kill} -INT $$(cat /run/uwsgi-spider.pid); \
		rm /run/uwsgi-spider.pid; \
	fi
	# @sudo rc-service mongodb stop
	# @sudo rc-service redis stop
	
	

clean:
	find . -name '*.pyc' -exec rm -f {} \;
	rm *.pid

# docker

docker-run:
	su -m spider -c "celery multi start spiderjob -A task.spider --pidfile=spider.pid --logfile=/run/spider.log --loglevel=INFO"
	su -m spider -c "uwsgi --ini-paste uwsgi.ini"

docker-stop:
	ps -ef | grep [c]elery | awk '{print $$2}' | xargs kill
	kill -INT $$(cat uwsgi.pid) 
	rm *.pid

.PHONY: clean update run stop redis mongodb docker-run docker-stop<commit_msg>clean<commit_after>SHELL := /bin/bash
kill := /bin/kill

redis:
	pgrep redis &>/dev/null || sudo rc-service redis start

mongodb:
	pgrep mongod &> /dev/null || sudo rc-service mongodb start

run: redis mongodb
	bash -c "source env/bin/activate; \
	celery multi start spiderjob -A task.spider --pidfile=run/spider.pid --logfile=run/spider.log --loglevel=INFO; \
	uwsgi --ini-paste uwsgi.ini; \
	deactivate"

update:
	bash -c 'source env/bin/activate; \
	cat requirements.txt | cut -d= -f1 | while read package; do \
		pip install -U $${package}; \
	done; \
	deactivate'

stop:
	@echo "kill celery"
	@if [[ -e /run/spider.pid ]]; then \
		ps -ef | grep [c]elery | awk '{print $$2}' | xargs ${kill}; \
	fi
	@echo "kill uwsgi"
	@if [[ -e /run/uwsgi-spider.pid ]]; then \
		${kill} -INT $$(cat /run/uwsgi-spider.pid); \
		rm /run/uwsgi-spider.pid; \
	fi
	# @sudo rc-service mongodb stop
	# @sudo rc-service redis stop
	
clean:
	find . -name '*.pyc' -exec rm -f {} \;
	rm *.pid

.PHONY: clean update run stop redis mongodb
{'fraction_non_alphanumeric': 0.1685630004214075, 'fraction_numerical': 0.002107037505267594, 'mean_word_length': 2.9369817578772803, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6368215', 'n_tokens_mistral': 1020, 'n_tokens_neox': 955, 'n_words': 271}