Does Vibe.D have a build-in terminate function, for when the library is run through a static initializer? I want to terminate the application when vibe.d throws an exception when for example opening a file.
I have a server listening using the listenHTTP function.
Try getEventDriver().exitEventLoop();, from here and here.
EDIT: There's a simpler version, the standalone function vibe.core.core.exitEventLoop.
Related
I am trying to find the best way to terminate an oci instance using the oci python library. I know that I can stop an instance with
base_compute.instance_action(instance_id, 'STOP')
However, I do not see a TERMINATE action in their documentation:https://docs.oracle.com/en-us/iaas/tools/oci-cli/2.21.5/oci_cli_docs/cmdref/compute/instance/action.html for the method. Any help with this would be great.
Please refer this document, it has the Oracle CLI command to terminate the instance.
Command: oci compute instance terminate [OPTIONS]
You can terminate an instance by calling either compute_client.terminate_instance or compute_client_composite_operations.terminate_instance_and_wait_for_state if you want your code wait for it to finish.
Here's an example from the Python SDK:
def terminate_instance(compute_client_composite_operations, instance):
print('Terminating Instance: {}'.format(instance.id))
compute_client_composite_operations.terminate_instance_and_wait_for_state(
instance.id,
wait_for_states=[oci.core.models.Instance.LIFECYCLE_STATE_TERMINATED]
)
print('Terminated Instance: {}'.format(instance.id))
print()
I am using figwheel,I want to dispatch events manually from REPL.
e.g after my app is connected to REPL
(in-ns 'my-re-frame.core)
(re-frame/dispatch-sync [::events/initialize-db])
I get following error
"RuntimeException Invalid token: ::events/initialize-db"
How I dispatch those events? and How to see status of app in REPL?
I think it's is because I'm using cider with fighweel in emacs and it tries to find conf with clj extention than clj
I have a weird behaviour on my application using QSqlDatabase.
This is the simple code i'm using:
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL", QString::number(this->m_id));
db.setHostName(SERVER_DATABASE_DATABASE_HOST);
db.setDatabaseName(SERVER_DATABASE_DATABASE_NAME);
db.setUserName(SERVER_DATABASE_USERNAME);
db.setPassword(SERVER_DATABASE_PASSWORD);
if( !db.open() ){
...
}
...
This snippet of code is executed inside the run() method of a QRunnable and i have n(n~20) of those Task that run asynchronusly without problems(no duplicated db connections, the connections are removed, ecc..).
The problem is that, after a lot of iteration, the execution crash.
The crash is replicable but not deterministic.
I tryied to run the application in debug mode but the debugger, stop at the line where i call the db.open() function, whitout further information(no stack trace, no signal).
My system specification:
MySQL v5.7.17 (community edition)
Mac OSX 10.11.6
Qt 5.7.0
Any suggestion is very appreciated
How do you terminate a run in SBT without exiting?
I'm trying CTRL+C but it exits SBT. Is there a way to only exit the running application while keeping SBT open?
From sbt version 0.13.5 you can add to your build.sbt
cancelable in Global := true
It is defined as "Enables (true) or disables (false) the ability to interrupt task execution with CTRL+C." in the Keys definition
If you are using Scala 2.12.7+ you can also cancel the compilation with CTRL+C. Reference https://github.com/scala/scala/pull/6479
There are some bugs reported:
https://github.com/sbt/sbt/issues/1442
https://github.com/sbt/sbt/issues/1855
In the default configuration, your runs happen in the same JVM that sbt is running, so you can't easily kill them separately.
If you do your run in a separate, forked JVM, as described at Forking, then you can kill that JVM (by any means your operating system offers) without affecting sbt's JVM:
run / fork := true
I've found the following useful when I have control over the main loop of the application being run from sbt.
I tell sbt to fork when running the application (in build.sbt):
fork in run := true
I also tell sbt to forward stdin from the sbt shell to the application (in build.sbt):
connectInput in run := true
Finally, in the main thread of the application, I wait for end-of-file on stdin and then shutdown the JVM:
while (System.in.read() != -1) {}
logger.warn("Received end-of-file on stdin. Exiting")
// optional shutdown code here
System.exit(0)
Of course, you can use any thread to read stdin and shutdown, not just the main thread.
Finally, start sbt, optionally switch to the subproject you want to run, run.
Now, when you want to stop the process, close its stdin by typing CTRL-D in the sbt shell.
Consider using sbt-revolver. We use it in our company and it's really handy.
For what you're asking can be done with:
reStart
reStop
Without need to configure build.sbt file.
Your can use this plugin by adding:
addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1")
To your project/plugins.sbt
If a bundle throws an exception in osgi, the stack-trace is printed on the osgi console. I want to be notified if a bundle throws an exception. I thought using osgi logging service could help about it. However I could not get it to work under Helios.
The question is how can I be notified if a bundle throws an exception in osgi Helios.
Or if osgi logging does the work, how can I get osgi logging to work in Helios? As much as I googled, there is apparently no implementation of osgi loggin service currently integrated in helios. I downloaded the equinox skd 3.6 from eclipse site that contains the bundle org.eclipse.equinox.log, however I could add it as dependency to my plugins, or install it in the osgi runtime.
Any help is really appreciated.
A bundle can only throw an exception when it is invoked. This nearly always when some other bundle invoked one of your published services, or because the bundle received a callback from the framework such as BundleActivator.start().
In the first case, OSGi has absolutely no way to know that an exception happened! Service invocations are direct method calls between two objects, and are not brokered or proxied by the OSGi framework. Therefore if you want to find out about the exception, you must catch it in the calling code.
In the second case, callbacks happen because some bundle caused them to happen. For example, a bundle will be started because some other bundle called Bundle.start(). In this case, an exception thrown from the BundleActivator.start() method would be wrapped in a BundleException that could be caught by the calling code.
So it's really all down to your code, unless you have some third-party bundles that invoke your services or start/stop your bundles (e.g. a web console, or a shell like GoGo). In this case it's down to the third party code. In most cases they should send messages to the LogService, so you should install the log bundle into your framework.
You said that you couldn't install the log bundle, but you didn't say why it failed, what the error message was etc! This kind if information is important if you want help resolving the problem.
You could try Pax Logging and a custom Log4J appender - Pax Logging provides implementations of the OSGi LogService etc as well as wrappers for common logging frameworks.
Do you want to do this purely to log/notify exceptions, or is there some other reason? An UncaughtExceptionHandler might be what you want if it's a case of managing your own or wrapped code.