## 2016-04-27 #lively4server

Getting the commit that last changed a file... e.g. the revision number of a file with git.

```
 git log -n1 --format=%H writetest.txt
```

### Working on lively4-server from within lively4

Ok, we talked about it and thought lets wait until the lively4-services project can gives us a live view on a terminal...

But then todays seminar came and here it is, the line of code that kills our lively server.

```
fetch("https://lively-kernel.org/lively4/_meta/exit").then(r => r.text()).then(t => lively.notify(t))
```

This would be the end, if the lively4-server would not automatically restart itself. This is a bit pointless, because we cannot directly edit the source code of the server. 

We could allow the server to directly edit its own source code, but that would only work until someone adds the first syntax error and then we are lost again.

And now we need a magic trick: our lively4.sh that restarts the server, just pulls in the latest changes from github before restarting the server. This allows us to use any means to fix the code on github and then the server will ressourect from the dead! And we are online again! 

We even could start simply start the lively4-server twice and they could edit each other indefinately as long as they dont force kill each other at the same time.


We could run it under https://lively-kernel.org/lively4S2 for example. And now we do.

We have two server running... wich are actually the same codebase, but use two different development speeds.

The first watches githup and has to be killed/restarted explicitly but will update automatically. The second server (lively4S2) will can edit itself or be edited through lively4 and will be killed/restarted whenever the httpServer.js files changes. I use a crude selfmade script to do this, but there should be many nice file watchers out there we should reuse. #Refactoring #TODO

The allows now for a really comfortable workflow: 

- edit the httpServer.js from within lively4 and press save
- lively4S2 gets restarted and the new behavior can immediatly be tried out
- using the liverly-sync tool, the changes can be commited and pushed to github
- by killing the first lively4-server explicitly, it will get the new code and before restarting itself

From now on I can work on the server code without having to log into via the terminal and ssh. 



