Created
August 23, 2018 13:09
-
-
Save renanpalmeira/c2505c23cc0848e38c61687b704dccf1 to your computer and use it in GitHub Desktop.
Deploy vintage Spring boot with supervisor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
TIME_TO_RELEASE=1 # in minutes | |
echo -e "\e[31mCompiling project\e[0m" | |
mvn clean package -DskipTests | |
echo -e "\e[34mInitial deploy\e[0m" | |
cp deploy/*.conf target/ \ | |
&& supervisorctl restart your-service-02 \ | |
echo -e "\e[32mNow initial blue/green deploy in $TIME_TO_RELEASE minutes\e[0m" | |
nohup sh -c "sleep $(($TIME_TO_RELEASE * 60)) && supervisorctl restart your-service-01" &>/dev/null & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-maven-plugin</artifactId> | |
<!-- Added this configuration in your pom to .jar run like a process in OS --> | |
<!-- https://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html --> | |
<configuration> | |
<executable>true</executable> | |
</configuration> | |
</plugin> | |
</plugins> | |
</build> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SITEDIR=/path/of/your/service | |
GIT_WORK_TREE=$SITEDIR git checkout -f | |
cd $SITEDIR | |
chmod +x deploy/deploy.sh | |
./deploy/deploy.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JAVA_OPTS="-Xmx1024M -Djava.security.egd=file:/dev/./urandom -Dspring.profiles.active=production -Dserver.port=$SERVICE_PORT" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[program:your-service-01] | |
process_name=%(program_name)s | |
environment=SERVICE_PORT=8181 | |
command=./path/of/your/service/target/your-0.0.1-SNAPSHOT.jar | |
autostart=true | |
autorestart=true | |
numprocs=1 | |
redirect_stderr=true | |
stdout_logfile=/opt/your-service/nohup.log | |
stopasgroup=true # most import to restart process of JVM | |
[program:your-service-02] | |
process_name=%(program_name)s | |
environment=SERVICE_PORT=8080 | |
command=./path/of/your/service/target/your-0.0.1-SNAPSHOT.jar | |
autostart=true | |
autorestart=true | |
numprocs=1 | |
redirect_stderr=true | |
stdout_logfile=/opt/your-service/nohup.log | |
stopasgroup=true # most import to restart process of JVM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Supervisord configuration https://gist.github.com/RenanPalmeira/c2505c23cc0848e38c61687b704dccf1#file-your-service-conf