keystone drop the database when used with child process - mongodb

Here is my problem.
When I use the following code in my program:
var spawn = require ('child_process').spawn;
...
var child = spawn ('node', ['my_program2', '...'], {stdio : ['ipc', fd_out, fd_err]});
my database is dropped.
The father program and the son program, use keystone.
I chose to use child_process because I have to have two different programs, the second launched by the first, and I have to listen to different socket.
Anyone know how to set keystone to avoid emptying the database or how to use the two programs with just one instance of keystone?
I thank you in advance.
ps: the Database I use is mongodb.

Sorry, error of mine ...
When creating a list, we use new keystone.List(), but when using it, it is keystone.list
Caps can lead to confusion.

Related

Discord.py mod log setup

I was wondering how one could make a command that sets up a mod log for a certain server, or start logging in one that already exists. This will probably require a database or JSON, anything is fine, as long as I can get it to work. Any help would be appreciated.
The way I would do this is with a .txt file that would contain all of the logs. I would add a line every time an event within the guild occurred, you could configure this to whatever events you wanted.
import datetime
#client.event
async def on_member_join(member):
with open("logs.txt", "a") as logsFile:
logsFile.write("\n[{}] {} just joined the server".format(datetime.datetime.now(),
member.name))
If you are currently using the logging module for discord.py or any other libraries, you can also use it for logging your own messages, either using the same or a separate logger.

Function dependent on previous Swift

I have three functions, each dependent on the previous.
let dbPath = createDBPath()
let db = openDatabase(dbPath!)
readQuestionsFromDB(db!)
The first line creates the database path ( if not gives a fatal error, as there is no point in continuing execution if I don't have access to the file stucture ).
The second line opens the database using the path (the unwrap is ok here, as if we don't have a path we'll have crashed by this point in any case).
The third line reads quiz questions from the database that needs to be opened, if the database has an issue it will also crash from within the function as if we can't read a DB there is something seriously wrong.
What is the best way to structure this? An if - let pyramid? I've split this into three functions to try to separate out functionality for readability. Perhaps I should pass the db and db path as class properties? I'm not sure...
I’d do this
if let dbPath = createDBPath(),
let db = openDatabase(dbPath) {
readQuestionsFromDB(db)
}
I don't see anything wrong with your current code, but if you really want to change the aesthetics of your code, you can call map on the optionals.
createDBPath().map(openDatabase).map(readQuestionsFromDB)

How connect two subjobs with tUnite

I'm trying to connect two "subjobs" with the object tUnite.
However I get an error :
Exception in component tHashInput_tUnite_3 (format)
java.lang.RuntimeException: The hash is not initialized : The hash must exist before you read from it
I think that is happening because a "subjob" finished before the other one.
It exists a way to do that or I must create two jobs?
Current structure
Note: Both tSortRow object (tri and tSortRow_2) have same structure.
Thank's for help!
Remove and then add a new tUnite.
It worked for me.

Reading an SB-Messaging Send Port properties using the Microsoft.BizTalk.ExplorerOM makes a breaking change

I am working on a PowerShell script making use of the Microsoft.BizTalk.ExplorerOM to dynamically update the SB-Messaging SAS key for BizTalk Receive Locations and Send Ports. This is to enable us to roll the SAS keys for our Service Bus queues, and update BizTalk with the new keys as painlessly as possible.
I have this working correctly for Receive Locations, but Send Ports are giving me a different issue.
As soon as I read the PrimaryTransport properties of the Send Port, it seems that some change is made under the covers, that then prevents SaveChanges from working, instead throwing an "Invalid or malformed XML data exception".
This is compared to the the ReceiveLocation, where I can read any of its properties, and then SaveChanges successfully.
Note that in both of this cases, no changes have been made by me. I am simply doing a Read, and then a Save.
Can anyone offer any advice as to what could be causing the issue, and any possible solutions to try?
Had this very same issue, when using Powershell to replace values in ServiceBus ReceiveLocations & SendPorts.
The problem is with the none valid xml symbols in the TransportTypeData, which are converted when the script reads them out in the PS cmd.
All none valid xml symbols (such as the one occuring for Namespace value, ) need to be converted to amp, and if I'm not mistaken even double amp:ed.
Here's an example article showing examples on what I mean by "double amp:ed":
How do I escape ampersands in XML so they are rendered as entities in HTML?
Hope this make sense, and if not, then let me know and I'll give it another go.
Just tried doing this from C#, seems to work ok:
var root = new Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer() { ConnectionString = "Data Source=(local);Initial Catalog=BizTalkMgmtDb;Integrated Security=SSPI;" };
var sendPort = root.SendPorts["xxxx.ServiceBusQueue"];
System.Diagnostics.Trace.TraceInformation(sendPort.PrimaryTransport.TransportTypeData);
sendPort .PrimaryTransport.TransportTypeData = sendPort.PrimaryTransport.TransportTypeData.Replace("RootManageSharedAccessKey", "MySharedAccessKey");
root.SaveChanges();

Opcode (APC/XCache), Zend, Doctrine, and Autoloaders

I am trying to use either APC or XCache as an opcode to cache my php pages. I am using it with Zend and Doctrine and it's having a problem with the autoloader.
If I try with APC, I get the following:
Fatal error: spl_autoload() [<a href='function.spl-autoload'>function.spl-autoload</a>]:
Class Doctrine_Event could not be loaded in
C:\\[mydir]\\library\\doctrine\\Doctrine\\Record.php on line 777
If I try with XCache I get the following:
PHP Fatal error: Cannot redeclare class Zend_Registry in
C:\\[mydir]\\library\\zendframework\\Zend\\Registry.php on line 0
I'm running Zend 1.9.1, Doctrine 1.1 on a windows box.
My bootstrap is as follows:
set_include_path(dirname(__FILE__).'/../library/zendframework'
. PATH_SEPARATOR . dirname(__FILE__).'/../library/doctrine'.....
require 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
$loader->suppressNotFoundWarnings(false);
$loader->setFallbackAutoloader(true);
From what I've read, using APC or xcache is almost a must for performance, but I can't seem to get it working. Any ideas?
You could put a "Zend_Session::writeClose(true);" at the end of your index.php.
This will write the session into a persistent state before necessary Objects (Zend_Loader etc.) get destructed.
Better: Register it as shutdown function.
So it will be executed even if you use exit(), die() or a fatal error occures:
register_shutdown_function(array('Zend_Session', 'writeClose'), true);
It is probably similar to the problem with custom session handling and APC-cache. If you have assigned a custom session handler it is registered with RSHUTDOWN in PHP. It is the same routine that APC uses and will therefor create an internal conflict in PHP and your custom session handler will not close in all situations.
So you will have to make sure you manually close the custom session handler at shutdown
Putting a "Zend_Session::writeClose(true);" at the end of your index.php is not the best way to do that in case you have any exit; calls in your scripts anywhere.
It is better to register a shutdown handler in this way:
function shutdown()
{
Zend_Session::writeClose(true);
}
register_shutdown_function('shutdown');
Put that in top of your index.php file to make sure that the shutdown procedure is registered before any other scripts are run.
Is there something else mucking the include path? Maybe try to log out the include path right before that line in your first APC example.
The XCache one is really weird. That project is pretty dead though, and I'd not trust it on PHP 5.2+. Try eaccelerator instead? We've had the best luck with it.
Benjamin Cremer, you're a life saver. While the above (original) problem is a special case of autoloading with sessions, closing the session seems to be a general solution for such cases. A note though:
Placing Zend_Session::writeClose(true); at the end of your scripts may not always cut it, since you may have exit;'s, die();'s, etc in your code. In this case, you can use
register_shutdown_function(array('Zend_Session', 'writeClose'), true);
or, simply
register_shutdown_function('session_write_close');
if you do not use Zend for sessions.