Skip to content
This repository was archived by the owner on Dec 10, 2018. It is now read-only.

how can i insert a date type data? #62

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
*~
*.log
.idea
*.pyc
*.pyo
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,18 @@ Please note: all tools/ scripts in this repo are released for use "AS IS" withou
Any use of these scripts and tools is at your own risk. There is no guarantee that they have been through thorough testing in a comparable environment and we are not responsible for any damage or data loss incurred with their use.
You are responsible for reviewing and testing any scripts you run thoroughly before use in any non-testing environment.

See [the wiki](https://github.com/10gen-labs/sleepy.mongoose/wiki) for documentation.
See [the original wiki](https://github.com/10gen-labs/sleepy.mongoose/wiki) for documentation.

This is a modified, optimised version of the original Sleepy Mongoose.
New features:

* You can mix POST and GET requests, it is the same parameter in different transfer method. Post has more precendency.

* You can specify listen host and port

* Disconnect method (_disconnect)

* Insert or update method (_insert_or_update), which is a shorcut to upsert update

* Shell script to start/stop or run in debug mode (Unix/Linux)

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
simplejson
pymongo
102 changes: 102 additions & 0 deletions sleepyServer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/bin/bash

### Paramaters ###

ADDRESS=localhost
PORT=27080

##################


# Action is the 1st parameter
action=$1
shift

python="`which python`"
dir="$(cd `dirname "$0"` && pwd)"
server="$dir/httpd.py"


# Process action
case ${action} in
# Start foreground mode with debug console
debug)
# Run it in foreground
"${python}" "${server}" $@
;;

start)
# Check if running
pgrep -f "${server}" >/dev/null
if [ $? -eq 0 ]; then
echo "The server is already running.";
exit 1;
fi

# Run it in background
"${python}" "${server}" $@ &>/dev/null &

# Check if the server is running (max 10s to wait)
for i in 1 2 3 4 5; do
sleep 1
wget -qO - ${ADDRESS}:${PORT}/_hello >/dev/null
res=$?
if [ ${res} -eq 0 ]; then
echo "The server has started successfully."
exit 0;
fi
done
killall ${server}
echo "The server has not started!"
exit 1;
;;

stop)
# Check if running
pgrep -f "${server}" >/dev/null
if [ $? -ne 0 ]; then
echo "The server is not running.";
exit 1;
fi
pkill -SIGINT -f "${server}" >/dev/null

pgrep -f "${server}" >/dev/null
res=$?

if [ ${res} -eq 0 ]; then
echo -n "Waiting for server to stop... "
for i in 5 4 3 2 1; do
echo -n -e "\b$i"
sleep 1
# If it is still running
pgrep -f "${server}" >/dev/null
res=$?
if [ ${res} -ne 0 ]; then break; fi
done

if [ ${res} -eq 0 ]; then
echo -e "\b Force kill server..."
pkill -f "${server}" >/dev/null
else
echo -e "\b\bOK"
fi
fi

pgrep -f "${server}" >/dev/null
res=$?

if [ ${res} -ne 0 ]; then
echo "The server stopped successfully."
else
echo "Some errors occured while stopping the server! Exit code: $res";
exit ${res}
fi
;;
test)
wget -qO - ${ADDRESS}:${PORT}/_hello
echo ""
;;
*)
echo "Usage: `basename "$0"` start|stop|debug|test"
;;
esac
Loading