Resolve "Flyway migrations"
This commit is contained in:
1 parent
fae59dd9bb
commit
41d6de7219
11 files changed
+132
-78
No files matched your search
@@ -1,3 +1,4 @@
|
|||||||
|
NETNEUTRALITY_TAG=latest
|
||||||
NETNEUTRALITY_BOT_ENV=dev
|
NETNEUTRALITY_BOT_ENV=dev
|
||||||
NETNEUTRALITY_BOT_TOKEN=
|
NETNEUTRALITY_BOT_TOKEN=
|
||||||
NETNEUTRALITY_BOT_PREFIX=$
|
NETNEUTRALITY_BOT_PREFIX=$
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ ARG API_PORT=9000
|
|||||||
EXPOSE ${API_PORT}
|
EXPOSE ${API_PORT}
|
||||||
|
|
||||||
COPY startup.sh ./
|
COPY startup.sh ./
|
||||||
COPY --from=build /target/netneutrality-jar-with-dependencies.jar ./
|
COPY --from=build /target/netneutrality.jar ./
|
||||||
|
|
||||||
RUN ["chmod", "+x", "./startup.sh"]
|
RUN ["chmod", "+x", "./startup.sh"]
|
||||||
CMD ["./startup.sh"]
|
CMD ["./startup.sh"]
|
||||||
+1
-2
@@ -5,7 +5,6 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
- netneutrality-db:/var/lib/mysql
|
- netneutrality-db:/var/lib/mysql
|
||||||
- ./sql:/docker-entrypoint-initdb.d
|
|
||||||
environment:
|
environment:
|
||||||
MYSQL_USER: 'java'
|
MYSQL_USER: 'java'
|
||||||
MYSQL_PASSWORD: 'password'
|
MYSQL_PASSWORD: 'password'
|
||||||
@@ -18,8 +17,8 @@ services:
|
|||||||
- internal
|
- internal
|
||||||
|
|
||||||
bot:
|
bot:
|
||||||
|
image: registry.bobert.me/anthorob/netneutrality:${NETNEUTRALITY_TAG:-latest}
|
||||||
container_name: bot
|
container_name: bot
|
||||||
build: ./
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
param (
|
||||||
|
[ValidateSet("migrate", "info", "validate", "clean", "baseline", "repair")]
|
||||||
|
[string]$Command = "info"
|
||||||
|
)
|
||||||
|
|
||||||
|
$envFile = ".env"
|
||||||
|
if (-not (Test-Path $envFile)) {
|
||||||
|
Write-Error ".env file not found in the current directory."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Get-Content $envFile | ForEach-Object {
|
||||||
|
if ($_ -match "^\s*([A-Za-z_][A-Za-z0-9_]*)=(.*)$") {
|
||||||
|
$name = $matches[1]
|
||||||
|
$value = $matches[2]
|
||||||
|
[System.Environment]::SetEnvironmentVariable($name, $value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$MYSQL_HOST = $env:MYSQL_HOST
|
||||||
|
$MYSQL_PORT = $env:MYSQL_PORT
|
||||||
|
$MYSQL_DATABASE = $env:MYSQL_DATABASE
|
||||||
|
|
||||||
|
if (-not $MYSQL_HOST -or -not $MYSQL_PORT -or -not $MYSQL_DATABASE) {
|
||||||
|
Write-Error "MYSQL_HOST, MYSQL_PORT, or MYSQL_DATABASE missing from .env"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
$env:LOCALDEV_FLYWAY_URL = "jdbc:mysql://${MYSQL_HOST}:${MYSQL_PORT}/${MYSQL_DATABASE}"
|
||||||
|
$env:FLYWAY_URL = $env:LOCALDEV_FLYWAY_URL
|
||||||
|
$env:FLYWAY_USER = $env:MYSQL_USER
|
||||||
|
$env:FLYWAY_PASSWORD = $env:MYSQL_PASSWORD
|
||||||
|
|
||||||
|
Write-Host "Ensuring database '$MYSQL_DATABASE' exists..."
|
||||||
|
$mysqlCommand = "CREATE DATABASE IF NOT EXISTS $MYSQL_DATABASE CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
|
||||||
|
& mysql --host=$MYSQL_HOST --port=$MYSQL_PORT --user=$env:MYSQL_USER --password=$env:MYSQL_PASSWORD -e $mysqlCommand
|
||||||
|
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
Write-Error "Failed to create database or connect to MySQL. Check your credentials or server status."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
.\mvnw flyway:$Command
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
COMMAND=${1:-info}
|
||||||
|
ENV_FILE=".env"
|
||||||
|
|
||||||
|
if [[ ! -f "$ENV_FILE" ]]; then
|
||||||
|
echo ".env file not found in the current directory."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Export variables from .env
|
||||||
|
export $(grep -E '^[A-Za-z_][A-Za-z0-9_]*=' "$ENV_FILE" | xargs)
|
||||||
|
|
||||||
|
if [[ -z "$MYSQL_HOST" || -z "$MYSQL_PORT" || -z "$MYSQL_DATABASE" ]]; then
|
||||||
|
echo "MYSQL_HOST, MYSQL_PORT, or MYSQL_DATABASE missing from .env"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
export LOCALDEV_FLYWAY_URL="jdbc:mysql://${MYSQL_HOST}:${MYSQL_PORT}/${MYSQL_DATABASE}"
|
||||||
|
export FLYWAY_URL="$LOCALDEV_FLYWAY_URL"
|
||||||
|
export FLYWAY_USER="$MYSQL_USER"
|
||||||
|
export FLYWAY_PASSWORD="$MYSQL_PASSWORD"
|
||||||
|
|
||||||
|
echo "Ensuring database '$MYSQL_DATABASE' exists..."
|
||||||
|
mysql -h"$MYSQL_HOST" -P"$MYSQL_PORT" -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" \
|
||||||
|
-e "CREATE DATABASE IF NOT EXISTS \`$MYSQL_DATABASE\` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
|
||||||
|
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
echo "Failed to create database or connect to MySQL. Check your credentials or server status."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
./mvnw flyway:"$COMMAND"
|
||||||
@@ -33,9 +33,9 @@
|
|||||||
<artifactId>flyway-maven-plugin</artifactId>
|
<artifactId>flyway-maven-plugin</artifactId>
|
||||||
<version>11.3.4</version>
|
<version>11.3.4</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<url>jdbc:mysql://localhost:3306/netneutrality</url>
|
<url>${env.FLYWAY_URL}</url>
|
||||||
<user>root</user>
|
<user>${env.FLYWAY_USER}</user>
|
||||||
<password></password>
|
<password>${env.FLYWAY_PASSWORD}</password>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
@@ -48,34 +48,45 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
<version>3.7.1</version>
|
<version>3.4.2</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<archive>
|
<archive>
|
||||||
<manifestEntries>
|
|
||||||
<Multi-Release>true</Multi-Release>
|
|
||||||
</manifestEntries>
|
|
||||||
<manifest>
|
<manifest>
|
||||||
<addClasspath>true</addClasspath>
|
|
||||||
<mainClass>${main.class}</mainClass>
|
<mainClass>${main.class}</mainClass>
|
||||||
</manifest>
|
</manifest>
|
||||||
</archive>
|
</archive>
|
||||||
<descriptorRefs>
|
|
||||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
|
||||||
</descriptorRefs>
|
|
||||||
<finalName>netneutrality</finalName>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.6.0</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>make-assembly</id> <!-- this is used for inheritance merges -->
|
<phase>package</phase>
|
||||||
<phase>package</phase> <!-- bind to the packaging phase -->
|
|
||||||
<goals>
|
<goals>
|
||||||
<goal>single</goal>
|
<goal>shade</goal>
|
||||||
</goals>
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<finalName>netneutrality</finalName>
|
||||||
|
<transformers>
|
||||||
|
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||||
|
<mainClass>${main.class}</mainClass>
|
||||||
|
</transformer>
|
||||||
|
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
|
||||||
|
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||||
|
<manifestEntries>
|
||||||
|
<Multi-Release>true</Multi-Release>
|
||||||
|
</manifestEntries>
|
||||||
|
</transformer>
|
||||||
|
</transformers>
|
||||||
|
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||||
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
@@ -179,6 +190,7 @@
|
|||||||
<groupId>org.flywaydb</groupId>
|
<groupId>org.flywaydb</groupId>
|
||||||
<artifactId>flyway-mysql</artifactId>
|
<artifactId>flyway-mysql</artifactId>
|
||||||
<version>11.3.4</version>
|
<version>11.3.4</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ package me.bobert.netneutrality;
|
|||||||
import io.sentry.Sentry;
|
import io.sentry.Sentry;
|
||||||
import me.bobert.netneutrality.core.LogHandler;
|
import me.bobert.netneutrality.core.LogHandler;
|
||||||
import me.bobert.netneutrality.core.command.CommandManager;
|
import me.bobert.netneutrality.core.command.CommandManager;
|
||||||
|
import me.bobert.netneutrality.core.db.DatabaseMigration;
|
||||||
import me.bobert.netneutrality.core.db.SessionManager;
|
import me.bobert.netneutrality.core.db.SessionManager;
|
||||||
import me.bobert.netneutrality.core.tasks.TaskManager;
|
import me.bobert.netneutrality.core.tasks.TaskManager;
|
||||||
import me.bobert.netneutrality.core.thread.ThreadManager;
|
import me.bobert.netneutrality.core.thread.ThreadManager;
|
||||||
@@ -67,7 +68,7 @@ public class NetNeutrality {
|
|||||||
throw new RuntimeException("No bot token provided, exiting.");
|
throw new RuntimeException("No bot token provided, exiting.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// DatabaseMigration.migrate();
|
DatabaseMigration.migrate();
|
||||||
SessionManager.getSessionFactory();
|
SessionManager.getSessionFactory();
|
||||||
CommandManager.init();
|
CommandManager.init();
|
||||||
MusicManager.initPlayerManager();
|
MusicManager.initPlayerManager();
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ public class DatabaseMigration {
|
|||||||
String dbUser = Settings.getInstance().get("MYSQL_USER", "root");
|
String dbUser = Settings.getInstance().get("MYSQL_USER", "root");
|
||||||
String dbPass = Settings.getInstance().get("MYSQL_PASSWORD", "");
|
String dbPass = Settings.getInstance().get("MYSQL_PASSWORD", "");
|
||||||
String dbHost = Settings.getInstance().get("MYSQL_HOST", "localhost");
|
String dbHost = Settings.getInstance().get("MYSQL_HOST", "localhost");
|
||||||
|
String dbUrl = String.format("jdbc:mysql://%s:3306/%s", dbHost, dbName);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Flyway flyway = Flyway.configure()
|
Flyway flyway = Flyway.configure()
|
||||||
.dataSource(String.format("jdbc:mysql://%s:3306/%s", dbHost, dbName), dbUser, dbPass)
|
.dataSource(dbUrl, dbUser, dbPass)
|
||||||
.baselineOnMigrate(true)
|
|
||||||
.load();
|
.load();
|
||||||
|
|
||||||
flyway.migrate();
|
flyway.migrate();
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class SessionManager {
|
|||||||
String dbUser = Settings.getInstance().get("MYSQL_USER", "root");
|
String dbUser = Settings.getInstance().get("MYSQL_USER", "root");
|
||||||
String dbPass = Settings.getInstance().get("MYSQL_PASSWORD", "");
|
String dbPass = Settings.getInstance().get("MYSQL_PASSWORD", "");
|
||||||
String dbHost = Settings.getInstance().get("MYSQL_HOST", "localhost");
|
String dbHost = Settings.getInstance().get("MYSQL_HOST", "localhost");
|
||||||
logger.info(String.format("Connecting to database '%s' at %s:3306 with user '%s'", dbName, dbHost, dbUser));
|
logger.info("Connecting to database '{}' at {}:3306 with user '{}'", dbName, dbHost, dbUser);
|
||||||
|
|
||||||
settings.put(Environment.JAKARTA_JDBC_URL, String.format("jdbc:mysql://%s:3306/%s", dbHost, dbName));
|
settings.put(Environment.JAKARTA_JDBC_URL, String.format("jdbc:mysql://%s:3306/%s", dbHost, dbName));
|
||||||
settings.put(Environment.JAKARTA_JDBC_USER, dbUser);
|
settings.put(Environment.JAKARTA_JDBC_USER, dbUser);
|
||||||
|
|||||||
@@ -1,27 +1,14 @@
|
|||||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
|
||||||
START TRANSACTION;
|
|
||||||
SET time_zone = "+00:00";
|
|
||||||
|
|
||||||
|
|
||||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
|
||||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
|
||||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
|
||||||
/*!40101 SET NAMES utf8mb4 */;
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Database: `netneutrality`
|
-- Database: `netneutrality`
|
||||||
--
|
--
|
||||||
CREATE DATABASE IF NOT EXISTS `netneutrality` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
CREATE DATABASE IF NOT EXISTS `netneutrality` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
USE `netneutrality`;
|
|
||||||
|
|
||||||
-- --------------------------------------------------------
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `blacklist`
|
-- Table structure for table `blacklist`
|
||||||
--
|
--
|
||||||
|
CREATE TABLE `blacklist` (
|
||||||
DROP TABLE IF EXISTS `blacklist`;
|
|
||||||
CREATE TABLE IF NOT EXISTS `blacklist` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`guild_id` varchar(255) NOT NULL,
|
`guild_id` varchar(255) NOT NULL,
|
||||||
`word` varchar(255) NOT NULL,
|
`word` varchar(255) NOT NULL,
|
||||||
@@ -36,9 +23,7 @@ CREATE TABLE IF NOT EXISTS `blacklist` (
|
|||||||
--
|
--
|
||||||
-- Table structure for table `guilds`
|
-- Table structure for table `guilds`
|
||||||
--
|
--
|
||||||
|
CREATE TABLE `guilds` (
|
||||||
DROP TABLE IF EXISTS `guilds`;
|
|
||||||
CREATE TABLE IF NOT EXISTS `guilds` (
|
|
||||||
`guild_id` varchar(255) NOT NULL,
|
`guild_id` varchar(255) NOT NULL,
|
||||||
`logging` tinyint(1) NOT NULL DEFAULT 0,
|
`logging` tinyint(1) NOT NULL DEFAULT 0,
|
||||||
`debug` tinyint(1) NOT NULL DEFAULT 1,
|
`debug` tinyint(1) NOT NULL DEFAULT 1,
|
||||||
@@ -51,9 +36,7 @@ CREATE TABLE IF NOT EXISTS `guilds` (
|
|||||||
--
|
--
|
||||||
-- Table structure for table `guild_settings`
|
-- Table structure for table `guild_settings`
|
||||||
--
|
--
|
||||||
|
CREATE TABLE `guild_settings` (
|
||||||
DROP TABLE IF EXISTS `guild_settings`;
|
|
||||||
CREATE TABLE IF NOT EXISTS `guild_settings` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`guild_id` varchar(255) NOT NULL,
|
`guild_id` varchar(255) NOT NULL,
|
||||||
`name` varchar(255) NOT NULL,
|
`name` varchar(255) NOT NULL,
|
||||||
@@ -67,9 +50,7 @@ CREATE TABLE IF NOT EXISTS `guild_settings` (
|
|||||||
--
|
--
|
||||||
-- Table structure for table `logging`
|
-- Table structure for table `logging`
|
||||||
--
|
--
|
||||||
|
CREATE TABLE `logging` (
|
||||||
DROP TABLE IF EXISTS `logging`;
|
|
||||||
CREATE TABLE IF NOT EXISTS `logging` (
|
|
||||||
`guild_id` varchar(255) NOT NULL,
|
`guild_id` varchar(255) NOT NULL,
|
||||||
`channel_id` varchar(255) NOT NULL,
|
`channel_id` varchar(255) NOT NULL,
|
||||||
`enabled` tinyint(1) NOT NULL DEFAULT 0,
|
`enabled` tinyint(1) NOT NULL DEFAULT 0,
|
||||||
@@ -81,9 +62,7 @@ CREATE TABLE IF NOT EXISTS `logging` (
|
|||||||
--
|
--
|
||||||
-- Table structure for table `log_message`
|
-- Table structure for table `log_message`
|
||||||
--
|
--
|
||||||
|
CREATE TABLE `log_message` (
|
||||||
DROP TABLE IF EXISTS `log_message`;
|
|
||||||
CREATE TABLE IF NOT EXISTS `log_message` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`guild_id` varchar(255) NOT NULL,
|
`guild_id` varchar(255) NOT NULL,
|
||||||
`channel_id` varchar(255) NOT NULL,
|
`channel_id` varchar(255) NOT NULL,
|
||||||
@@ -102,9 +81,7 @@ CREATE TABLE IF NOT EXISTS `log_message` (
|
|||||||
--
|
--
|
||||||
-- Table structure for table `tasks`
|
-- Table structure for table `tasks`
|
||||||
--
|
--
|
||||||
|
CREATE TABLE `tasks` (
|
||||||
DROP TABLE IF EXISTS `tasks`;
|
|
||||||
CREATE TABLE IF NOT EXISTS `tasks` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`task_id` varchar(255) NOT NULL,
|
`task_id` varchar(255) NOT NULL,
|
||||||
`task_class` varchar(255) NOT NULL,
|
`task_class` varchar(255) NOT NULL,
|
||||||
@@ -118,9 +95,7 @@ CREATE TABLE IF NOT EXISTS `tasks` (
|
|||||||
--
|
--
|
||||||
-- Table structure for table `web_users`
|
-- Table structure for table `web_users`
|
||||||
--
|
--
|
||||||
|
CREATE TABLE `web_users` (
|
||||||
DROP TABLE IF EXISTS `web_users`;
|
|
||||||
CREATE TABLE IF NOT EXISTS `web_users` (
|
|
||||||
`id` varchar(255) NOT NULL,
|
`id` varchar(255) NOT NULL,
|
||||||
`email` mediumtext NOT NULL,
|
`email` mediumtext NOT NULL,
|
||||||
`token` varchar(255) NOT NULL,
|
`token` varchar(255) NOT NULL,
|
||||||
@@ -130,10 +105,6 @@ CREATE TABLE IF NOT EXISTS `web_users` (
|
|||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
|
|
||||||
--
|
|
||||||
-- Constraints for dumped tables
|
|
||||||
--
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Constraints for table `blacklist`
|
-- Constraints for table `blacklist`
|
||||||
--
|
--
|
||||||
@@ -157,8 +128,3 @@ ALTER TABLE `logging`
|
|||||||
--
|
--
|
||||||
ALTER TABLE `log_message`
|
ALTER TABLE `log_message`
|
||||||
ADD CONSTRAINT `fk_log_guilds` FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`guild_id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
ADD CONSTRAINT `fk_log_guilds` FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`guild_id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
COMMIT;
|
|
||||||
|
|
||||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
|
||||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
|
||||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
|
||||||
+11
-13
@@ -15,30 +15,28 @@ _term() {
|
|||||||
trap _term TERM
|
trap _term TERM
|
||||||
trap _term INT
|
trap _term INT
|
||||||
|
|
||||||
|
API_PORT="${API_PORT:-9000}"
|
||||||
|
MYSQL_HOST="${MYSQL_HOST:-localhost}"
|
||||||
|
MYSQL_PORT="${MYSQL_PORT:-3306}"
|
||||||
|
MYSQL_DATABASE="${MYSQL_DATABASE:-netneutrality}"
|
||||||
|
|
||||||
if [ ! -f /usr/bin/nc ]; then
|
if [ ! -f /usr/bin/nc ]; then
|
||||||
echo "nc not found. Exiting."
|
echo "nc not found. Exiting."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z $API_PORT ]; then
|
|
||||||
API_PORT=9000;
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z $MYSQL_HOST ]; then
|
|
||||||
MYSQL_HOST="localhost"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z $MYSQL_PORT ]; then
|
|
||||||
MYSQL_PORT=3306
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Waiting 10 seconds for database to start.."
|
echo "Waiting 10 seconds for database to start.."
|
||||||
sleep 10
|
sleep 10
|
||||||
|
|
||||||
echo "Checking if MySQL / MariaDB is started.."
|
echo "Checking if MySQL / MariaDB is started.."
|
||||||
if /usr/bin/nc -z $MYSQL_HOST $MYSQL_PORT; then
|
if /usr/bin/nc -z $MYSQL_HOST $MYSQL_PORT; then
|
||||||
echo "Database OK. Starting bot..";
|
echo "Database OK. Starting bot..";
|
||||||
/opt/java/openjdk/bin/java -jar /app/netneutrality-jar-with-dependencies.jar &
|
|
||||||
|
export FLYWAY_URL="jdbc:mysql://${MYSQL_HOST}:${MYSQL_PORT}/${MYSQL_DATABASE}"
|
||||||
|
export FLYWAY_USER="${MYSQL_USER}"
|
||||||
|
export FLYWAY_PASSWORD="${MYSQL_PASSWORD}"
|
||||||
|
|
||||||
|
/opt/java/openjdk/bin/java -jar /app/netneutrality.jar &
|
||||||
|
|
||||||
pid=$!
|
pid=$!
|
||||||
wait "$pid"
|
wait "$pid"
|
||||||
|
|||||||
Reference in new issue
Block a user