Skip to content

Instantly share code, notes, and snippets.

@renanpalmeira
Created August 23, 2018 13:09
Show Gist options
  • Save renanpalmeira/c2505c23cc0848e38c61687b704dccf1 to your computer and use it in GitHub Desktop.
Save renanpalmeira/c2505c23cc0848e38c61687b704dccf1 to your computer and use it in GitHub Desktop.
Deploy vintage Spring boot with supervisor
#!/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 &
<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>
#!/bin/bash
SITEDIR=/path/of/your/service
GIT_WORK_TREE=$SITEDIR git checkout -f
cd $SITEDIR
chmod +x deploy/deploy.sh
./deploy/deploy.sh
JAVA_OPTS="-Xmx1024M -Djava.security.egd=file:/dev/./urandom -Dspring.profiles.active=production -Dserver.port=$SERVICE_PORT"
[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
@renanpalmeira
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment