Added swarm auto setup to orborus
This commit is contained in:
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
version: '3'
|
version: '3'
|
||||||
services:
|
services:
|
||||||
frontend:
|
frontend:
|
||||||
#build: ./frontend
|
build: ./frontend
|
||||||
image: ghcr.io/frikky/shuffle-frontend:nightly
|
image: ghcr.io/frikky/shuffle-frontend:nightly
|
||||||
container_name: shuffle-frontend
|
container_name: shuffle-frontend
|
||||||
hostname: shuffle-frontend
|
hostname: shuffle-frontend
|
||||||
@@ -16,7 +16,7 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- backend
|
||||||
backend:
|
backend:
|
||||||
#build: ./backend
|
build: ./backend
|
||||||
image: ghcr.io/frikky/shuffle-backend:nightly
|
image: ghcr.io/frikky/shuffle-backend:nightly
|
||||||
container_name: shuffle-backend
|
container_name: shuffle-backend
|
||||||
hostname: ${BACKEND_HOSTNAME}
|
hostname: ${BACKEND_HOSTNAME}
|
||||||
|
|||||||
@@ -64,6 +64,7 @@
|
|||||||
"react-router": "^4.3.1",
|
"react-router": "^4.3.1",
|
||||||
"react-router-dom": "^4.3.1",
|
"react-router-dom": "^4.3.1",
|
||||||
"react-scripts": "^4.0.1",
|
"react-scripts": "^4.0.1",
|
||||||
|
"react-shepherd": "^3.3.6",
|
||||||
"reactstrap": "^7.1.0",
|
"reactstrap": "^7.1.0",
|
||||||
"shellwords": "^0.1.1",
|
"shellwords": "^0.1.1",
|
||||||
"simplebar": "^4.2.3",
|
"simplebar": "^4.2.3",
|
||||||
|
|||||||
@@ -560,11 +560,15 @@ const Admin = (props) => {
|
|||||||
if (responseJson.reason !== undefined) {
|
if (responseJson.reason !== undefined) {
|
||||||
alert.error(responseJson.reason);
|
alert.error(responseJson.reason);
|
||||||
} else {
|
} else {
|
||||||
alert.error("Failed creating suborg");
|
alert.error("Failed creating suborg. Please try again");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
alert.success("Successfully created suborg!");
|
alert.success("Successfully created suborg. Reloading in 3 seconds!");
|
||||||
setSelectedUserModalOpen(false);
|
setSelectedUserModalOpen(false);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.reload()
|
||||||
|
}, 2500);
|
||||||
}
|
}
|
||||||
|
|
||||||
setOrgName("");
|
setOrgName("");
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import React, { useEffect } from "react";
|
import React, { useEffect, useContext } from "react";
|
||||||
import { makeStyles } from "@material-ui/core/styles";
|
import { makeStyles } from "@material-ui/core/styles";
|
||||||
import { useTheme } from "@material-ui/core/styles";
|
import { useTheme } from "@material-ui/core/styles";
|
||||||
|
|
||||||
import SecurityFramework from '../components/SecurityFramework.jsx';
|
import SecurityFramework from '../components/SecurityFramework.jsx';
|
||||||
|
import { ShepherdTour, ShepherdTourContext } from 'react-shepherd'
|
||||||
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Badge,
|
Badge,
|
||||||
@@ -2439,7 +2441,104 @@ const Workflows = (props) => {
|
|||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const tourOptions = {
|
||||||
|
defaultStepOptions: {
|
||||||
|
classes: "shadow-md bg-purple-dark",
|
||||||
|
scrollTo: true
|
||||||
|
},
|
||||||
|
useModalOverlay: true,
|
||||||
|
tourName: workflows,
|
||||||
|
exitOnEsc: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
//classes: "custom-class-name-1 custom-class-name-2",
|
||||||
|
const newSteps = [
|
||||||
|
{
|
||||||
|
id: "intro",
|
||||||
|
scrollTo: true,
|
||||||
|
beforeShowPromise: function() {
|
||||||
|
return new Promise(function(resolve) {
|
||||||
|
setTimeout(function() {
|
||||||
|
window.scrollTo(0, 0);
|
||||||
|
resolve();
|
||||||
|
}, 500);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
classes: "shepherd-button-primary",
|
||||||
|
style: {
|
||||||
|
backgroundColor: "red",
|
||||||
|
color: "white",
|
||||||
|
},
|
||||||
|
text: "Next",
|
||||||
|
type: "next"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
highlightClass: "highlight",
|
||||||
|
showCancelLink: true,
|
||||||
|
text: [
|
||||||
|
"React-Shepherd is a JavaScript library for guiding users through your React app."
|
||||||
|
],
|
||||||
|
when: {
|
||||||
|
show: () => {
|
||||||
|
console.log("show step 1");
|
||||||
|
},
|
||||||
|
hide: () => {
|
||||||
|
console.log("hide step 1");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "second",
|
||||||
|
attachTo: {
|
||||||
|
element: "second-step",
|
||||||
|
on: "top"
|
||||||
|
},
|
||||||
|
text: [
|
||||||
|
"Yuk eksplorasi hasil Tes Minat Bakat-mu dan rekomendasi <b>Jurusan</b> dan Karier."
|
||||||
|
],
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
classes: "btn btn-info",
|
||||||
|
text: "Kembali",
|
||||||
|
type: "back"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
classes: "btn btn-success",
|
||||||
|
text: "Saya Mengerti",
|
||||||
|
type: "cancel"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
when: {
|
||||||
|
show: () => {
|
||||||
|
console.log("show stepp");
|
||||||
|
},
|
||||||
|
hide: () => {
|
||||||
|
console.log("complete step");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
showCancelLink: false,
|
||||||
|
scrollTo: true,
|
||||||
|
modalOverlayOpeningPadding: 4,
|
||||||
|
useModalOverlay: false,
|
||||||
|
canClickTarget: false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
function TourButton() {
|
||||||
|
const tour = useContext(ShepherdTourContext);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Button variant="contained" color="primary" onClick={tour.start}>
|
||||||
|
Start Tour
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//import { ShepherdTour, ShepherdTourContext } from 'react-shepherd'
|
||||||
const WorkflowView = () => {
|
const WorkflowView = () => {
|
||||||
|
/*
|
||||||
if (workflows.length === 0) {
|
if (workflows.length === 0) {
|
||||||
return (
|
return (
|
||||||
<div style={emptyWorkflowStyle}>
|
<div style={emptyWorkflowStyle}>
|
||||||
@@ -2467,6 +2566,7 @@ const Workflows = (props) => {
|
|||||||
</div>
|
</div>
|
||||||
<div style={{ display: "flex" }}>
|
<div style={{ display: "flex" }}>
|
||||||
<Button
|
<Button
|
||||||
|
id="second-step"
|
||||||
color="primary"
|
color="primary"
|
||||||
style={{ marginTop: "20px" }}
|
style={{ marginTop: "20px" }}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
@@ -2487,11 +2587,15 @@ const Workflows = (props) => {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
var workflowDelay = -150
|
var workflowDelay = -150
|
||||||
var appDelay = -75
|
var appDelay = -75
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={viewStyle}>
|
<div style={viewStyle}>
|
||||||
|
|
||||||
<div style={workflowViewStyle}>
|
<div style={workflowViewStyle}>
|
||||||
<div style={{ display: "flex" }}>
|
<div style={{ display: "flex" }}>
|
||||||
<div style={{ flex: 3 }}>
|
<div style={{ flex: 3 }}>
|
||||||
@@ -2895,6 +2999,11 @@ const Workflows = (props) => {
|
|||||||
const loadedCheck =
|
const loadedCheck =
|
||||||
isLoaded && isLoggedIn && workflowDone ? (
|
isLoaded && isLoggedIn && workflowDone ? (
|
||||||
<div>
|
<div>
|
||||||
|
{/*
|
||||||
|
<ShepherdTour steps={newSteps} tourOptions={tourOptions}>
|
||||||
|
<TourButton />
|
||||||
|
</ShepherdTour>
|
||||||
|
*/}
|
||||||
<Dropzone
|
<Dropzone
|
||||||
style={{
|
style={{
|
||||||
maxWidth: window.innerWidth > 1366 ? 1366 : 1200,
|
maxWidth: window.innerWidth > 1366 ? 1366 : 1200,
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
@@ -624,6 +625,42 @@ func findActiveSwarmNodes() (int64, error) {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get IP
|
||||||
|
func getLocalIP() string {
|
||||||
|
addrs, err := net.InterfaceAddrs()
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, address := range addrs {
|
||||||
|
// check the address type and if it is not a loopback the display it
|
||||||
|
if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
|
||||||
|
if ipnet.IP.To4() != nil {
|
||||||
|
return ipnet.IP.String()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkSwarmService(ctx context.Context) {
|
||||||
|
// https://docs.docker.com/engine/reference/commandline/swarm_init/
|
||||||
|
ip := getLocalIP()
|
||||||
|
log.Printf("[DEBUG] Attempting swarm setup on %s", ip)
|
||||||
|
req := swarm.InitRequest{
|
||||||
|
ListenAddr: fmt.Sprintf("0.0.0.0:2377", ip),
|
||||||
|
AdvertiseAddr: fmt.Sprintf("%s:2377", ip),
|
||||||
|
}
|
||||||
|
|
||||||
|
ret, err := dockercli.SwarmInit(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("[WARNING] Swarm init: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("[DEBUG] Swarm info: %s\n\n", ret)
|
||||||
|
}
|
||||||
|
|
||||||
// Initial loop etc
|
// Initial loop etc
|
||||||
func main() {
|
func main() {
|
||||||
log.Println("[INFO] Setting up execution environment")
|
log.Println("[INFO] Setting up execution environment")
|
||||||
@@ -685,6 +722,10 @@ func main() {
|
|||||||
log.Printf("[INFO] Setting up Docker environment. Downloading worker and App SDK!")
|
log.Printf("[INFO] Setting up Docker environment. Downloading worker and App SDK!")
|
||||||
|
|
||||||
initializeImages()
|
initializeImages()
|
||||||
|
if swarmConfig == "run" {
|
||||||
|
checkSwarmService(ctx)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//workerName := "worker"
|
//workerName := "worker"
|
||||||
//workerVersion := "0.1.0"
|
//workerVersion := "0.1.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user