How to run nohup command in mesos without spanning multiple jobs - marathon

I'm trying to run a one script file in mesos in background by using nohup command trying, but unfortunately the problem is the script executing successfully but the same scripts spanning as multiple jobs and running all jobs in background.
How can I handle the jobs with out spanning multi jobs, restrict a single jobs after scaling the application in marathon.
**marathon_sample.json**
{
"id": "/dps/sample",
"cmd": "nohup sh /tmp/marathon_test/marathon_sample.sh & >> /tmp/marathon_test/marathon_test.log",
"cpus": 0.1,
"mem": 512,
"disk": 1,
"instances": 0,
"container": null,
"constraints": [
[
"hostname",
"LIKE",
"(lltws0gbeot.sdi.corp.bankofamerica.com)"
]
],
"portDefinitions": [
{
"port": 0,
"protocol": "tcp",
"name": null,
"labels": null
}
]
}
**marathon_sample.sh**
#! /bin/sh
while [ true ] ;
do
echo 'Hello Marathon test application'
sleep 5 ;
done
Can any one help me to run "marathon_sample.sh" in mesos as a background job.

What's the point of running nohup in Marathon? Marathon (resp. Mesos) is supposed to be the "init system" responsible for keeping your job alive and running. You should simplify the command to:
"cmd": "sh /tmp/marathon_test/marathon_sample.sh",
Logs from stdout and stderr are automatically being stored into task's workdir. There's no point to write out of your workdir.

Related

How to connect jupyter to an existing environment WITHOUT altering that environment in any way

One can currently connect jupyter to an existing environment, if one installs ipykernel in that particular environment first (and then creates a "kernel" for that environment").
My question is how can that be achieved without touching the environment.
I tried creating a kernelspec.json file manually:
"argv": [
"/path/to/envs/myenv/bin/python",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "myenv",
"language": "python",
"metadata": {
"debugger": true
}
}
but that doesn't work.
Any hints (even regarding why my request is not sensible) are appreciated.

Running multiple Visual Studio Tasks in Parallel

I'm trying to run a long-lived background task in visual studio (tsc --watch) while also running my app as two separate tasks. So, (app)-[dependsOn]->(tsc --watch). But, it appears that the app task waits for the tsc command to finish before it executes, which is a problem since it runs forever.
I'm simplifying my problem to show the actual issue I'm running into, but should hopefully guide me down the right path.
I have two task in my tasks.json file:
{
"label": "Echo 1",
"command": "echo",
"type": "shell",
"args": [
"echo1"
],
"group": {
"isDefault": true,
"kind": "build"
},
"dependsOrder": "parallel",
"dependsOn": [
"Sleep 5"
]
},
{
"label": "Sleep 5",
"type": "shell",
"command": "sleep",
"isBackground": true,
"args": [
"5"
]
}
Echo 1 -depends on-> Sleep 5
According to visual studio documentation the sleep task should be running in the background allowing the Echo task to do it's thing. But, whenever I execute the Echo 1 task, it waits until Sleep 5 is finished and THEN it actually executes the echo task.
> Executing task: sleep 5 <
Terminal will be reused by tasks, press any key to close it.
> Executing task: echo echo1 <
echo1
Terminal will be reused by tasks, press any key to close it.
I've tried adding the background property detailed in the documentation, but the editor shows a popup with the message Property background is not allowed. whenever I add that field.
Am I missing something else to ensure that the Sleep 5 task doesn't block the Echo 1 task?
I've tried already tried using the presentation with panel: dedicated/new to each task so they don't use the same terminal (not even sure if that's how visual studio executes it's tasks).

Run flutter app on multiple connected devices/emulators simultaneously [duplicate]

This question already has answers here:
Flutter Hot Reload to multiple devices
(6 answers)
Closed 3 years ago.
How can I run my flutter app on multiple devices at the same time without having to go through the sequential procedure of: select a device -> run, select other device -> run, etc.?
Using:
Android Studio 3.2.1
Flutter 1.0.0
Dart 2.1.0
Run command in terminal:
flutter run -d all
or create a script (e.g. runall.sh in root):
#!/usr/bin/env bash
flutter run -d all
and go to "Run" -> "Edit Configurations". Press "+" in upper left corner -> select "Bash". Then set:
Name: runall
Script: [path to runall.sh script]
Interpreter Path: /bin/bash
Select "runall" instead of "main.dart" beside run icon. Performing run (also through shortcut) will now run app on all devices.
Drawback: You'll have to enter "r" followed by Enter in run terminal for hot reload. Icon and shortcut does not work. Hot reload is performed on all devices though.
Just a workaround for now. I'm pretty sure the flutter plugin will cover this soon.
There are many ways to do this as previously answered. If you use VS Code instead of Android Studio as your Flutter IDE, this is how you can use the VSC launch configuration and tasks to run concurrently from a single launch and have hot reload enabled for all devices.
If you have an issue with executing flutter run -d all this is an alternative solution will which let you specify the devices that should run.
Ensure that the devices you specify are available when running flutter devices.
Your current launch.json file may look something like this:
{
"version": "0.2.0",
"configurations": [
{
"name": "Flutter",
"type": "dart",
"request": "launch",
"flutterMode": "debug"
}
]
}
Setup
You will need to update this launch.json file and create tasks.json in the same .vscode folder that is in your application's root directory.
Paste only the below code into launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Flutter-All",
"preLaunchTask": "Flutter-Launch-All",
"type": "dart",
},
{
"name": "Flutter-iOS",
"preLaunchTask": "Flutter-Launch-iOS",
"type": "dart",
},
{
"name": "Flutter-Android",
"preLaunchTask": "Flutter-Launch-Android",
"type": "dart",
},
{
"name": "Flutter-Web",
"preLaunchTask": "Flutter-Launch-Web",
"type": "dart",
}
],
}
Paste only the below code into tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "Flutter-Launch-All",
"dependsOn": [
"Flutter-Launch-iOS",
"Flutter-Launch-Android",
"Flutter-Launch-Web"
]
},
{
"label": "Flutter-Launch-iOS",
"type": "shell",
"command": "flutter run -d 'iPhone 11' "
},
{
"label": "Flutter-Launch-Android",
"type": "shell",
"command": "flutter run -d 'AOSP on IA Emulator' "
},
{
"label": "Flutter-Launch-Web",
"type": "shell",
"command": "flutter run -d 'Chrome' "
}
]
}
Replace the device names accordingly ('iPhone 11', 'AOSP on IA Emulator', 'Chrome').
Firing up all devices
Press the F5 key.
And you're done.
If the F5 shortcut to Start Debugging does not work for you, navigate to Debug & Run on the side panel and select the Flutter-All Configuration you've just created and then Run.
You will then see the terminal window appear and will able to switch between the individual hot-reload sessions running (as Tasks in their own shell).
Some Background
We use 'Compound Tasks' by way of the dependsOn option on a Task and not 'Compounds' which are for Configurations.
As it is not possible to launch Configurations concurrently, only sequentially, we use tasks which can run concurrently.
Hence, the "Flutter-All" Configuration executes the tasks of the iOS, Android and Web Configurations.
If using Compounds, a Configuration will need to complete before the next runs which is not what we want.
With Tasks we can choose to execute them sequentially however by default they will execute concurrently when using the dependsOn option.
//Do not use this unless you want to use Configurations only by testing them sequentially and not tasks
"compounds": [
{
"name": "Flutter-All",
"configurations": ["Flutter-iOS", "Flutter-Android", "Flutter-Web"],
}
]
If you don't want to use the command line directly each time, you can do the following workaround:
Download bashsupport plugin (link)
Create new configuration of bash, leave the script field empty, and in the interperter options cell insert:flutter run -d all. It should look something like:
If step two didn't work, create a file call something like run_all.sh in your root project. and put the next lines there(assuming that bin/bash is the path to your bash):
#!/bin/bash
flutter run -d all
type in your terminal:chmod 755 run_all.sh.
Specify run_all.sh in your configuration and bin/bash as your interprter path.
Remove flutter run -d all from interperter options.
It should look something like:
You can always have an external tool watch the files for you and trigger a hot reload.
Flutter supports certain signals to trigger a hot reload natively
--pid-file Specify a file to write the process id to. You can send SIGUSR1 to trigger a hot reload and SIGUSR2 to trigger a hot restart.
Here is an fast example:
#!/usr/bin/env bash
set -euo pipefail
# Remove previous pid files
rm -f /tmp/flutter.pid
# Run in a loop a hot reload call in a subshell
(while true
do
# Wait for flutter to start before monitoring pid
while [[ ! -f /tmp/flutter.pid ]]; do sleep 1; done;
# Send hot reload signal when files change
find lib/ -name '*.dart' | entr -n -d -p kill -USR1 $(cat /tmp/flutter.pid)
done) &
# Run all devices under 1 pid
flutter run -d all --pid-file /tmp/flutter.pid
Idea from: https://medium.com/#kikap/how-to-automatically-hot-reload-flutter-when-dart-source-files-change-6e8fdb523004
For more details on entr: http://eradman.com/entrproject/entr.1.html

Launching Multiple Simultaneous Tasks in VS Code

I have a single "project" with 3 separate codebases (loaded into a single workspace), each of which has its own long-running npm start task. I want to run all of these at the same time. This isn't too hard if you just go to Terminal -> Run Task 3 times and launch each individually, but since I do this every day and sometimes multiple times per day, it'd be nice to simplify it into running a single command that launches all 3 at once, preferrably in a split terminal (though not necessary), rather than each having their own tab. Anyone know if this is possible?
What you want to do is make a new separate task and list the 3 tasks you want to run as dependancies. For example, in your tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "Task1",
// ...
},
{
"label": "Task2",
// ...
},
{
"label": "Task3",
// ...
},
{
"label": "Run 3 Tasks",
"dependsOn": ["Task1", "Task2", "Task3"]
}
]
}
The default behavior for dependancies will be to run tasks in parellel. This can be changed with the dependsOrder tag.
https://code.visualstudio.com/Docs/editor/tasks

How to run several tasks in VSCode

I am trying to migrate to VSCode and having a problem with setting-up tasks. It is easy to define tasks in tasks.json but I would like to run several tasks simultaneously (which I can't).
Here is my use-case: I have two watchers in my project (one for gulp and another one for webpack). Plus I want to be able to run webpack task separately. When I run one of the watchers I cannot run anything else - VSCode requires me to terminate the running task at first.
In Visual Studio I used Task Runner where several tasks were running simultaneously. Is it possible to achieve the same in VSCode?
Using compound tasks, you can specify dependsOn and dependsOrder on a separate task, and run them in parallel like this:
{
"label": "start-tasks",
"dependsOrder": "parallel",
"dependsOn": [
"taskOne",
"taskTwo"
]
}
The problem is that "Run Test Task" and "Run Build Task" do not execute all tasks in that specific group. Usually you get a drop down selection so you can choose which task to execute. Since you have specified one of the tasks as default, the selection will be skipped and instead the default task is executed.
You can work around that by adding dependencies. Take the following example:
{
"version": "2.0.0",
"tasks": [
{
"label": "Echo 1",
"command": "echo",
"type": "shell",
"args": [ "echo1" ],
"group": {
"kind": "build",
"isDefault": true
},
"dependsOn":["Echo 2"]
},
{
"label": "Echo 2",
"type": "shell",
"command": "echo",
"args": [ "echo2" ],
"group": "build"
}
]
}