alfazema.club-etc

commit 32cad3e5608465165a5c007b0616931203099b4f

Author: Pedro Lucas Porcellis <porcellis@eletrotupi.com>

Add openrc services

 init.d/hometown-sidekiq | 41 +++++++++++++++++++++++++++++++++++++++++
 init.d/hometown-streaming | 41 +++++++++++++++++++++++++++++++++++++++++
 init.d/hometown-web | 40 ++++++++++++++++++++++++++++++++++++++++


diff --git a/init.d/hometown-sidekiq b/init.d/hometown-sidekiq
new file mode 100755
index 0000000000000000000000000000000000000000..49765e0c40147c08db63bbff7fbed17c3367523f
--- /dev/null
+++ b/init.d/hometown-sidekiq
@@ -0,0 +1,41 @@
+#!/sbin/openrc-run
+
+name="hometown-sidekiq"
+description="hometown sidekiq service"
+HOMETOWN_USER=${HOMETOWN_USER:-deployer}
+LOGS=/var/log/hometown-sidekiq.log
+
+depend() {
+	need net
+	use redis
+}
+
+start_pre() {
+	checkpath -f "$LOGS" -m 644 -o "$HOMETOWN_USER:$HOMETOWN_USER"
+}
+
+start() {
+	ebegin "Starting $name"
+	cd /srv/hometown
+	export RAILS_ENV=production
+	export DB_POOL=25
+	export MALLOC_ARENA_MAX=2
+
+	start-stop-daemon \
+		-u ${HOMETOWN_USER} \
+		-1 "$LOGS" \
+		-2 "$LOGS" \
+		--background \
+		--make-pidfile \
+		--pidfile /run/$name.pid \
+		--exec /usr/bin/bundle -- \
+			exec sidekiq -c 25
+
+	eend $?
+}
+
+stop() {
+	ebegin "Stopping $name"
+	start-stop-daemon --stop --exec /usr/bin/bundle --pidfile /run/$name.pid
+	eend $?
+}




diff --git a/init.d/hometown-streaming b/init.d/hometown-streaming
new file mode 100755
index 0000000000000000000000000000000000000000..3774aac1967e7a6500bbd8f8ddcf562149f1d246
--- /dev/null
+++ b/init.d/hometown-streaming
@@ -0,0 +1,41 @@
+#!/sbin/openrc-run
+
+name="hometown-streaming"
+description="hometown streaming service"
+HOMETOWN_USER=${HOMETOWN_USER:-deployer}
+LOGS=/var/log/hometown-streaming.log
+
+depend() {
+	need net
+	use redis
+}
+
+start_pre() {
+	checkpath -f "$LOGS" -m 644 -o "$HOMETOWN_USER:$HOMETOWN_USER"
+}
+
+start() {
+	ebegin "Starting $name"
+	cd /srv/hometown
+	export NODE_ENV=production
+	export PORT=4000
+	export STREAMING_CLUSTER_NUM=1
+
+	start-stop-daemon \
+		-u ${HOMETOWN_USER} \
+		-1 "$LOGS" \
+		-2 "$LOGS" \
+		--background \
+		--make-pidfile \
+		--pidfile /run/$name.pid \
+		--exec /usr/bin/node -- \
+			./streaming
+
+	eend $?
+}
+
+stop() {
+	ebegin "Stopping $name"
+	start-stop-daemon --stop --exec /usr/bin/node --pidfile /run/$name.pid
+	eend $?
+}




diff --git a/init.d/hometown-web b/init.d/hometown-web
new file mode 100755
index 0000000000000000000000000000000000000000..cca31c569364e619401effbdbf3b3c995f56fe2c
--- /dev/null
+++ b/init.d/hometown-web
@@ -0,0 +1,40 @@
+#!/sbin/openrc-run
+
+name="hometown-web"
+description="hometown web service"
+HOMETOWN_USER=${HOMETOWN_USER:-deployer}
+LOGS=/var/log/hometown-web.log
+
+depend() {
+	need net
+	use redis
+	use postgresql
+}
+
+start_pre() {
+	checkpath -f "$LOGS" -m 644 -o "$HOMETOWN_USER:$HOMETOWN_USER"
+}
+
+start() {
+	ebegin "Starting $name"
+	cd /srv/hometown
+	export RAILS_ENV=production
+
+	start-stop-daemon \
+		-u ${HOMETOWN_USER} \
+		-1 "$LOGS" \
+		-2 "$LOGS" \
+		--background \
+		--make-pidfile \
+		--pidfile /run/$name.pid \
+		--exec /usr/bin/bundle -- \
+			exec puma -C config/puma.rb
+
+	eend $?
+}
+
+stop() {
+	ebegin "Stopping $name"
+	start-stop-daemon --stop --exec /usr/bin/bundle --pidfile /run/$name.pid
+	eend $?
+}