Added swarm auto setup to orborus
This commit is contained in:
+2
-2
@@ -1,7 +1,7 @@
|
||||
version: '3'
|
||||
services:
|
||||
frontend:
|
||||
#build: ./frontend
|
||||
build: ./frontend
|
||||
image: ghcr.io/frikky/shuffle-frontend:nightly
|
||||
container_name: shuffle-frontend
|
||||
hostname: shuffle-frontend
|
||||
@@ -16,7 +16,7 @@ services:
|
||||
depends_on:
|
||||
- backend
|
||||
backend:
|
||||
#build: ./backend
|
||||
build: ./backend
|
||||
image: ghcr.io/frikky/shuffle-backend:nightly
|
||||
container_name: shuffle-backend
|
||||
hostname: ${BACKEND_HOSTNAME}
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
"react-router": "^4.3.1",
|
||||
"react-router-dom": "^4.3.1",
|
||||
"react-scripts": "^4.0.1",
|
||||
"react-shepherd": "^3.3.6",
|
||||
"reactstrap": "^7.1.0",
|
||||
"shellwords": "^0.1.1",
|
||||
"simplebar": "^4.2.3",
|
||||
|
||||
@@ -560,11 +560,15 @@ const Admin = (props) => {
|
||||
if (responseJson.reason !== undefined) {
|
||||
alert.error(responseJson.reason);
|
||||
} else {
|
||||
alert.error("Failed creating suborg");
|
||||
alert.error("Failed creating suborg. Please try again");
|
||||
}
|
||||
} else {
|
||||
alert.success("Successfully created suborg!");
|
||||
alert.success("Successfully created suborg. Reloading in 3 seconds!");
|
||||
setSelectedUserModalOpen(false);
|
||||
|
||||
setTimeout(() => {
|
||||
window.location.reload()
|
||||
}, 2500);
|
||||
}
|
||||
|
||||
setOrgName("");
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import React, { useEffect } from "react";
|
||||
import React, { useEffect, useContext } from "react";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import { useTheme } from "@material-ui/core/styles";
|
||||
|
||||
import SecurityFramework from '../components/SecurityFramework.jsx';
|
||||
import { ShepherdTour, ShepherdTourContext } from 'react-shepherd'
|
||||
|
||||
|
||||
import {
|
||||
Badge,
|
||||
@@ -2439,7 +2441,104 @@ const Workflows = (props) => {
|
||||
</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 = () => {
|
||||
/*
|
||||
if (workflows.length === 0) {
|
||||
return (
|
||||
<div style={emptyWorkflowStyle}>
|
||||
@@ -2467,6 +2566,7 @@ const Workflows = (props) => {
|
||||
</div>
|
||||
<div style={{ display: "flex" }}>
|
||||
<Button
|
||||
id="second-step"
|
||||
color="primary"
|
||||
style={{ marginTop: "20px" }}
|
||||
variant="outlined"
|
||||
@@ -2487,11 +2587,15 @@ const Workflows = (props) => {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
var workflowDelay = -150
|
||||
var appDelay = -75
|
||||
|
||||
|
||||
return (
|
||||
<div style={viewStyle}>
|
||||
|
||||
<div style={workflowViewStyle}>
|
||||
<div style={{ display: "flex" }}>
|
||||
<div style={{ flex: 3 }}>
|
||||
@@ -2895,6 +2999,11 @@ const Workflows = (props) => {
|
||||
const loadedCheck =
|
||||
isLoaded && isLoggedIn && workflowDone ? (
|
||||
<div>
|
||||
{/*
|
||||
<ShepherdTour steps={newSteps} tourOptions={tourOptions}>
|
||||
<TourButton />
|
||||
</ShepherdTour>
|
||||
*/}
|
||||
<Dropzone
|
||||
style={{
|
||||
maxWidth: window.innerWidth > 1366 ? 1366 : 1200,
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"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
|
||||
func main() {
|
||||
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!")
|
||||
|
||||
initializeImages()
|
||||
if swarmConfig == "run" {
|
||||
checkSwarmService(ctx)
|
||||
|
||||
}
|
||||
|
||||
//workerName := "worker"
|
||||
//workerVersion := "0.1.0"
|
||||
|
||||
Reference in New Issue
Block a user