On my Minecraft server (Spigot 1.9.4) , I have some log sometimes.
[10:18:15] [Server thread/INFO]: [#: 1 blocks cloned]
[10:18:15] [Server thread/INFO]: [#: 1 blocks cloned]
[10:18:15] [Server thread/INFO]: [#: 1 blocks cloned]
[10:18:15] [Server thread/INFO]: [#: 1 blocks cloned]
[10:18:15] [Server thread/INFO]: [#: 1 blocks cloned]
[10:18:15] [Server thread/INFO]: [#: 1 blocks cloned]
[10:18:15] [Server thread/INFO]: [#: 1 blocks cloned]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: 1 blocks cloned]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot access blocks outside of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
[10:18:15] [Server thread/INFO]: [#: Cannot summon the object out of the world]
But I don't know the origin of this log, i try verbose mode without success.
I have this log every 12 minutes and 48 seconds exactly !
28.06 09:52:39
28.06 10:05:27
28.06 10:18:15
My plugin list :
Plugins (43): dynmap, WorldEdit, hNether, Skript, OpenInv, Essentials,
LogBlock, Lift, ClearLag, Craftconomy3, AutoMessage, Modifyworld,
Multiverse-Core, WorldGuard, ProtocolLib, BungeePortals, UberRecipes,
HorseProtect, Multiverse-SignPortals, VoxelSniper, EssentialsChat,
BlocksHub, PermissionsEx, BlocksHub-LogBlock, Multiverse-Portals,
SuperVanish, Vault, ChairStairs, EssentialsSpawn, BungeeTabListPlus,
JSONAPI, AreaShop, pvparena, TimeGivesYouMoney, MobArena,
PerWorldInventory, LWC, HolographicDisplays, QuickShop, Citizens,
Shopkeepers, BlocksHub-WorldGuard, Multiverse-NetherPortals
Someone did have the same problem ?
Do you know how trace this to the source ?
Thanks
This is almost certainly a command block being used, rather than a plugin.
On the "admin broadcast" that command blocks also trigger once someone uses an operator command, the "username" name it uses is #.
Related
I've got the following code, which I know is being run:
ReadDelegate * del = [[ReadDelegate alloc] init];
CFReadStreamRef readStream;
CFWriteStreamRef writeStream;
CFStreamCreatePairWithSocketToHost(NULL, (CFStringRef)(#"server.com"), port, &readStream, &writeStream);
NSInputStream * readSock = (__bridge_transfer NSInputStream*)readStream;
[readSock setDelegate:del];
[readSock scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
NSOutputStream * writeSock = (__bridge_transfer NSOutputStream*)writeStream;
[writeSock scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
NSLog(#"Open socket");
[readSock open];
[writeSock open];
[writeSock write:(uint8_t*)("request\0\0\0") maxLength:10];
while (YES) {
//I'm skipping over inconsequential stuff
}
NSLog(#"finished reading");
[readSock close];
[writeSock close];
return [del getMessage];
My ReadDelegate class is declared like #interface ReadDelegate : NSObject <NSStreamDelegate> and includes a - (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode. That particular function just has a print statement in it to see if it's ever being called. It's not.
I know for a fact that the connection is being opened because my server is receiving the "request\0\0\0" message and the server is sending the file (I have tests in other environments which can receive the file just fine).
However, as mentioned, the ReadDelegate object declared in the beginning (del) never receives the stream message, even once (to say the stream is open or whatever).
Why is the delegate not being called?
It looks like your stream doesn't receive events because of your while loop.
Every new event from a stream can be handled in a new iteration of run loop. But the new iteration can not be started because the current one never finishes.
There have been a couple of NSTask related questions, but after paging through them I still have no idea what to do.
I'm writing a frontend for a java server in Cocoa, launched by java -Xmx1024M -Xms1024M -jar server.jar nogui (I've left out the nogui arg in my current code so as not to fill up my computer with unnecessary orphaned instances of server).
My current code correctly runs the .jar file; now I need a way to capture (and parse) output and send input to the process.
server = [[NSTask alloc] init];
pipe = [NSPipe pipe];
NSArray *args = [NSArray arrayWithObjects:#"-Xms1024M",
#"-Xmx1024M",
#"-jar",
#"server.jar",
nil];
[server setLaunchPath:#"/usr/bin/java"];
[server setCurrentDirectoryPath:#"MyApp.app/Contents/Resources/"];
[server setArguments:args];
[server setStandardOutput:pipe];
[server setStandardInput:pipe];
[server launch];
I've read up on NSPipe and NSTask and everything, but I can't seem an answer geared towards my problem:
Live, parsed (RegEx?) output to NSTextView or NSTableView.
Input from NSTextField
EDIT: Or should I use launchd? How would I do that?
You need to make two pipes: one for the task's standard input, and another for the task's standard output. What you're doing right now connects the task's output to its own input.
Something like this:
#interface ServerController : NSObject
#property (strong) NSFileHandle *standardInput;
#property (strong) NSFileHandle *standardOutput;
#end
#implementation ServerController
...
- (void)launchServer {
NSPipe *standardInputPipe = [NSPipe pipe];
self.standardInput = standardInputPipe.fileHandleForWriting;
NSPipe *standardOutputPipe = [NSPipe pipe];
self.standardOutput = standardOutputPipe.fileHandleForReading;
...
server.standardInput = standardInputPipe;
server.standardOutput = standardOutputPipe;
[server launch];
}
...
Now you can write to the server by sending the writeData: message to the standardInput property of the ServerController instance. To read from the server, you'll want to use either readInBackgroundAndNotify or readabilityHandler on the standardOutput property.
I need to read the last added line to a log file, in realtime, and capture that line being added.
Something similar to Tail -f.
So my first attempt was to use Tail -f using NSTask.
I can't see any output using the code below:
NSTask *server = [[NSTask alloc] init];
[server setLaunchPath:#"/usr/bin/tail"];
[server setArguments:[NSArray arrayWithObjects:#"-f", #"/path/to/my/LogFile.txt",nil]];
NSPipe *outputPipe = [NSPipe pipe];
[server setStandardInput:[NSPipe pipe]];
[server setStandardOutput:outputPipe];
[server launch];
[server waitUntilExit];
[server release];
NSData *outputData = [[outputPipe fileHandleForReading] readDataToEndOfFile];
NSString *outputString = [[[NSString alloc] initWithData:outputData encoding:NSUTF8StringEncoding] autorelease];
NSLog (#"Output \n%#", outputString);
I can see the output as expected when using:
[server setLaunchPath:#"/bin/ls"];
How can i capture the output of that tail NSTask?
Is there any alternative to this method, where I can open a stream to file and each time a line is added, output it on screen? (basic logging functionality)
This is a little tricky to do your way, as readDataToEndOfFile will wait until tail closes the output stream before returning, but tail -f never closes the output stream (stdout). However, this is actually pretty simple to do with basic C I/O code, so I whipped up a simple FileTailer class that you can check out. It's not anything fancy, but it should show you how it's done. Here're the sources for FileTailer.h, FileTailer.m, and a test driver.
The meat of the class is pretty simple. You pass it a block, and it reads a character from the stream (if possible) and passes it to the block; if EOF has been reached, it waits a number of seconds (determined by refresh) and then tries to read the stream again.
- (void)readIndefinitely:(void (^)(int ch))action
{
long pos = 0L;
int ch = 0;
while (1) {
fseek(in, pos, SEEK_SET);
int ch = fgetc(in);
pos = ftell(in);
if (ch != EOF) {
action(ch);
} else {
[NSThread sleepForTimeInterval:refresh];
}
}
}
You can call it pretty simply, like this:
FileTailer *tail = [[[FileTailer alloc] initWithStream:stdin refreshPeriod:3.0] autorelease];
[tail readIndefinitely:^ void (int ch) { printf("%c", ch); }];
(Caveat: I wrote the FileTailer class pretty fast, so it's kind of ugly right now and should be cleaned up a bit, but it should serve as a decent example on how to read a file indefinitely, à la tail -f.)
Here's a way to use "tail -f logfile" via NSTask in Objective-C:
asynctask.m -- sample code that shows how to implement asynchronous stdin, stdout & stderr streams for processing data with NSTask
...
Being a GUI-less application (i.e. a Foundation-based command line tool), asynctask.m runs an NSRunLoop manually
to enable the use of asynchronous "waitForDataInBackgroundAndNotify" notifications. In addition, asynctask.m
uses pthread_create(3) and pthread_detach(3) for writing more than 64 KB to the stdin of an NSTask.
Source code of asynctask.m available at: http://www.cocoadev.com/index.pl?NSPipe
Is it possible to setup an Instruments run programmatically from my code? For instance, I'd like to structure my code something like this where startTrace might setup a specific probe for the current thread and start recording while stopTrace would stop recording. I would be writing the content of those routines using the Instruments API that is the subject of this question.
-(void)myInterestingMethod
{
[self startTrace];
// do something interesting and performance critical
[self stopTrace];
}
If the above isn't available, is setting up my own DTrace probe a viable alternative?
Doesn't look like there's anything straight-forward, but there is an instruments command-line tool. Here's some quick+dirty code that will invoke it and sample CPU usage for the calling process
static void sampleMe() {
// instruments -t '/Developer/Applications/Instruments.app/Contents/Resources/templates/CPU Sampler.tracetemplate' -p 26838 -l 5000
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:#"/usr/bin/instruments"];
[task setArguments:[NSArray arrayWithObjects:
#"-t",
#"/Developer/Applications/Instruments.app/Contents/Resources/templates/CPU Sampler.tracetemplate",
#"-p",
[NSString stringWithFormat:#"%ld", getpid()],
#"-l",
#"5000",
nil]];
[task setCurrentDirectoryPath:NSHomeDirectory()];
[task setStandardInput:[NSPipe pipe]];
[task setStandardOutput:[NSPipe pipe]];
[task setStandardError:[NSPipe pipe]];
[task launch];
// purposely leak everything since I can't be bothered to figure out lifetimes
}
After invocation a file named instrumentscli0.trace will be in your home directory.
Update: Instruments 4.0 offers DTSendSignalFlag in the DTPerformanceSession for iOS apps.
I'm trying to figure out how to make this piece of code from a previous question work, but I'm stuck on the part on how to 'register' a NSFileHandleReadToEndOfFileCompletionNotification.
This is my code:
NSTask *topTask = [NSTask new];
[topTask setLaunchPath:#"/usr/bin/top"];
[topTask setArguments:[NSArray arrayWithObjects:#"-s", #"1", #"-l", #"3600", #"-stats", #"pid,cpu,time,command", nil]];
NSPipe *outputPipe = [NSPipe pipe];
[topTask setStandardOutput:outputPipe];
[topTask launch];
... which runs fine until I add this:
[[outputPipe fileHandleForReading] readToEndOfFileInBackgroundAndNotify];
... which causes the program to freeze. And when I add this:
NSString *outputString = [[[NSString alloc] initWithData:[[notification userInfo] objectForKey:NSFileHandleNotificationDataItem] encoding:NSUTF8StringEncoding] autorelease];
... the code doesn't compile and I get the !warning
'notification' undeclared.
Any assistance on this matter earns copious amounts of gratitude on my behalf.
Running top with those parameters in the command line will cause it to continually print out stats and it will never write EOF. That's why -readToEndOfFileInBackgroundAndNotify runs forever.
It sounds like you may just want to read the first iteration and then kill the task.
As for the error, it sounds like you simply don't have a variable named notification in the method containing that line.